Configuring Azure Redis session cache for ASP.NET MVC 5 web application not possible in web.config - redis

We want to use the Azure Redis service as a session cache for our MVC 5 web application.
For that we use Nuget Microsoft.Web.RedisSeessionStateProvider, which was updated to v3.0.2 recently.
However, putting that specific version in the web.config throws an error saying that the session state provider must inherit from SessionStateStoreProviderBase (namespace System.Web.SessionState).
The RedisSessionStateProvider v3.0.2 from the Nuget inherits from SessionStateStoreProviderAsyncBase (namespace Microsoft.AspNet.SessionState), and hence doesn't work.
The web application is running .NET Framework 4.72! So it must be compatible with v3.x according to the release notes.
The only solution so far is to fall back to version 2.x of the Nuget and use that instead.
What am I missing?

Related

Add/remove serilog logging level overrides at run time

I am using Serilog in .Net 6 WebApi and the required serilog settings, including default logging level and few overrides, are currently being set via appsettings. However, I am looking for a way to dynamically add/remove logging level override for additional namespaces during runtime so that I can capture additional logs on demand for troubleshooting issues, without redeploying the application with setting changes. Is this possible? Any guidance available on how this can be achieved?
Thanks!
You can implement a custom configuration provider in .NET Core which reads the configuration from Database. And you may need to implement Reload option as well. So when you update the database - your configuration will get updated. Here are some references which may help you.
Implement a custom configuration provider in .NET
A Refreshable SQL Server Configuration Provider for .NET Core
Creating a custom ConfigurationProvider for a Entity Framework Core source

user secrets file gets ignored in asp.net core 6

I have two projects targeted .net 6 and there are no any explicit declarations for using user secrets (I remember, it was required in previous versions to use AddUserSecrets()). Though, one project gets the right config from secrets.json, but another one - tries to get it from appsettings.json.
So, I'm wondering, what's the issue? How the behavior was changed in .net 6?
In .Net6, WebApplication.CreateBuilder initializes a new instance of the WebApplicationBuilder class with preconfigured defaults. The initialized WebApplicationBuilder (builder) provides default configuration and calls AddUserSecrets when the EnvironmentName is Development.
As long as you initialize your web application using the WebHost.CreateDefaultBuilder method, ASP.NET Core automatically picks up your configuration from the secrets.json file in .Net6. If you initialize your application manually or not .Net6, make sure to call the AddUserSecrets-method.
refer to this

Blazor .NET Core app not deploying on IIS

I'm trying to deploy a blazor app on IIS following the article below
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio
I've installed IIS version 10.0 using the following settings:
I then created the site and changed the application pool to No Managed Code
I created a new Blazor app and deployed it immediately without changing a thing (so I know there's not a problem with the code). Looking in the project properties it's using .NET Core 3.1
I noticed there was no web.config file when I built the Release version.
I copied the Release version to the website directory.
Browsing to the site gives me a 403.14 - Forbidden error.
I read in another article to try configuring the Mapping Handlers this was the current state of the handlers:
I added a module mapping like so:
I now get a 500 error:
The web.config file currently looks like this:
I then read to add this aspCore line to the configuration file:
After that it looks like it loads but with none of the formatting.
I assumed hosting a Blazor site on IIS would be a simple thing to do, would someone be able to point me to where I am going wrong?

Deploy ASPNET Core (ASPNET 5) application on IIS Virtual Directory

I want to deploy a ASPNET Core (old ASPNET 5) application to IIS.
I was able to deploy to a new Web Site following this guide. But I want to deploy it to a virtual directory.
I tried to follow the same steps (but using Virtual Directory instead of Web Site), but I was unsuccessful. The page does not respond, and DNX is not launched.
I am using runtime 1.0.0-rc1-update1.
Check if in web.config file in handlers section in aspNetCore handler you have not directoryPath="*" statement. If there is just delete it, but only this statement not an entirehandler. Check on image below.
I remember that I had a problem with that.
web.config
in my expreience for launch aspnet core project on iis you should try to this steps:
1- dont use source for lunch because iis need web.config so just lunch after publish, publish create a web.config to you
2- be sure that install the core modules to your iis
3- dont use shared app pool , create a new one and set Clr version to "No managed code"
i hope this can be useful

WCF 4 Router Service configuration issue

I've created a WCF 4 Router Service and am hosting it in IIS7. It works fine on my development machine, but when I deploy to the QA server is returns the following message:
The configuration section 'routing' cannot be read because it is missing a section declaration
The section it's complaining about is the standard WCF4 routing section:
<routing>
<filters>
<filter name="MatchAllFilter1" filterType="MatchAll" />
</filters>
<filterTables>
<filterTable name="ServiceRouterTable">
<add filterName="MatchAllFilter1" endpointName="WCF_XXXService" />
</filterTable>
</filterTables>
</routing>
This should be stock standard, but I'm receiving the above error from IIS. Does anyone have any suggestions on how I can fix this issue?
Ok, finally found the solution here:
The root configuration files (the
machine.config file and the root
Web.config file) for the .NET
Framework 4 (and therefore ASP.NET 4)
have been updated to include most of
the boilerplate configuration
information that in ASP.NET 3.5 was
found in the application Web.config
files. Because of the complexity of
the managed IIS 7 and IIS 7.5
configuration systems, running ASP.NET
3.5 applications under ASP.NET 4 and under IIS 7 and IIS 7.5 can result in
either ASP.NET or IIS configuration
errors.
We recommend that you upgrade ASP.NET
3.5 applications to ASP.NET 4 by using the project upgrade tools in Visual
Studio 2010, if practical. Visual
Studio 2010 automatically modifies the
ASP.NET 3.5 application's Web.config
file to contain the appropriate
settings for ASP.NET 4.
READ MORE HERE:
aspnet4 breaking-changes
A quick Google turned up this:
If you upgrade a site to .NET 4, and don’t upgrade the application pool to use .NET 4, you will get this. The machine.config file for .NET 4 declares this section, and earlier version did not have it (unless you manually added it).
In IIS 7, with the site select, choose Basic Settings in the right pane. This will bring up a dialog that contains the name of your application pool. Then select the application pools tree node and the application pool from the list that shows up. Choose Basic Settings from the right pane here, and you can change the framework version.
From here
Can you try re-running aspnet_regiis from the FrameworkXXX\microsoft.net\v4.0.30319 folder and reset IIS?
Check the .Net framework associated with the site's app pool.
If you need to change it, run iisreset -force after to ensure changes take effect.