Reload root web.config without restaring IIS - asp.net

My app is being moved from a server running IIS6 to a server running IIS7.5.
The new server defaults to Medium Trust. As this is a shared server and I am consuming some third-party assemblies, I don't want to ask to run my app under Full Trust.
I have copied web_mediumtrust.config to mycustom_mediumtrust.config.
I have added this second line to the root web.config but the new MyCustom trust level remains unavailable.
<trustLevel name="High" policyFile="web_hightrust.config" />
<trustLevel name="MyCustom" policyFile="mycustom_mediumtrust.config" />
<trustLevel name="Medium" policyFile="web_mediumtrust.config" />
Is there a way to force a reload of the root web.config without restarting IIS and all the other apps?

Related

Stop bad handler mappings from re-appearing

I'm on Windows 10 running an ASP.Net web app locally in IIS Express. Initially when I was trying to serve my app on localhost I introduced some bad handler mappings in my IIS Express options for the app. I figured out I didn't have IIS ASP.Net installed as part of IIS and fixed that. Then I removed the bad mappings and everything works. But every time I restart my app in IIS the bad mappings re-appear, and I have to remove them again. How do I permanently delete or remove these bad mappings? Thanks in advance for any replies.
I think I figured it out. I added lines to remove the bad handlers in my Web.cong in the system.webServer section ( the Web.config in my projects root folder). The problem was happing everytime I published to the local server. Seems intorducing these lines replaces the Web.config in the app's root folder for the server. Adding these lines seems to fix the problem. Here's the lines I added:
<handlers>
<remove name="Start Module" />
<remove name="Start" />
</handlers>

how to bind part of url to iis?

Environment:
asp.net core app
IIS
I want to map these two urls to different iis website with different application pools.
These two websites have the same domain e.g example.com but the only different part is after slash i want another websites handles file upload because of the time needed the connection to be open and so on
- http://example.com
- http://example.com/upload
so that i can do something like this in web.config in just the second url
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
or as my app is an asp.net core app be able to increase request time out
<aspNetCore processPath=".\abc.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" requestTimeout="00:10:00" />
is the above solution is logical?
how can i achieve having these two bindings?
are there any other solutions for handling such scenario when an upload for security concerns and other reasons need to be separated from other part of the web app?
They can't be different websites (as listed in IIS Manager) but they can be different app pools.
In IIS Manager, right-click on the subfolder ("upload") and click "Convert to Application". Then you can assign it to whichever app pool you like.
If it is not a subfolder of the site already, then you can right-click the root of the website and click 'Add Application'. Then select the name ("upload"), the app pool, and the physical path where the files are.

.NET Core IISIntegration configuration

Pretty new to .NET Core, and am trying to understand how everything works together when using IIS integration.
A couple of questions: If I want my site to run over HTTPS, do i need to configure my WebBuilder with a certificate, or should i be selecting HTTPS on the binding in IIS manager, or both?
Does the UseUrls WebBuilder method also instruct IIS what port is should listen on? How does IIS know which port it should talk to the .NET Core application on?
When you host your .NET Core app behind IIS, IIS is acting as a reverse proxy to Kestrel web server. IIS will receive the HTTP request and pass it to Kestrel, the magic happen inside a new IIS module called AspNetCoreModule that you have to install on your server. As usual, to configure your IIS application you'll be using a web.config file in which you'll find a description of how IIS is interacting with your app: timeouts, pathes of the application, environment variables and so on... For instance, mine look like that:
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore
requestTimeout="00:20:00"
processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="true">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="development" /> <!-- value could be "development", "staging" or "production"-->
</environmentVariables>
</aspNetCore>
</system.webServer>
The reason why you want to set it up that way is that Kestrel is a very light weight and nervous web server but it's missing a layer of applicative features that IIS can add up: Windows authentication via Kerberos, restarting the app in case of a crash, pool management...
I like a lot this article regarding this topic: https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
For HTTPS, it's enough to configure IIS to listen on a secure HTTPS port and to define the certificate only on IIS.
UseUrls() won't be taken into account by IIS, it will work the other way around, IIS will tell your app on which port it should be listening to, UseUrls() will be taken into account if you launch your app directly.

MVC4: Preload application without having access to IIS

I want to have my MVC application to warm up the application after it is being restarted, so the next initial loading will cost almost no time.
The problem is that I do not have the access to the server computer IIS.
I have searched of how to do it, and I found this:
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>
But this code requires access to the server computer.
How can I do it only with my application and web.config?

IIS web.config in classic asp

I have a classic asp site hosted in IIS 7.5. Currently it allows me to upload only <200KB files. The hosting provider said that I should put that limit in web.config. I do not know how to increase the limit using web.config.
ASP Limits properties are by default located in the server applicationHost.config, if you don't have access to it, your hosting provider must delegate ASP feature to lower levels.
Once it is done, put this in your web.config:
<system.webServer>
<asp>
<limits maxRequestEntityAllowed="200000000" />
</asp>
</system.webServer>
Note that if the server is not delegating this feature properly, you will get an error when trying to do a request to your app.

Resources