Change target structure in IIS
In my ASP.NET 5 application, I am creating a dropdown thanks to the HtmlHelper. Everything works fine on localhost except in production, we have a 500 server error.
I managed to find the composition that is being executed on github and it was executing in the MVC lib, exactly to the DefaultHtmlGenerator class:
This is done when we want to display the dropdown depending on the SelectList parameter that we pass.
We can see that the comment indicates that we should use at least version 4.5 of the framework. At the end of the stacktrace, we see the production version of the framework:
However, version 4.5 is installed on our server and I tried to insert the web.config file into the wwwroot of the project to force the target structure:
But this does not work, and we correctly indicate the structure that we want to use in our project. json:
So my question is, can we use compilation targetFramework = "4.5" and httpRuntime targetFramework = "4.5" to force IIS to use version 4.5?
source to share
Note
You are trying to run IIS managed code. You cannot do this. IIS is no longer in control of the process. Basically, IIS is going to run the EXE and is going to redirect requests to it. What is it.
Check the below procedure to properly deploy your application DNX
to IIS. Or better, read the documentation right here: http://docs.asp.net/en/latest/publishing/iis.html
Requirements
- Windows 7 or better
- Windows Server 2008 R2 or better
- Is IIS installed
Procedure
First make sure you have the HTTP Platform Handler ( x86 / 64 ) installed in your IIS .
Publish your application to the file system and run the contents of the folder \artifacts\bin\MyWebApp\Release\Publish
and copy it to your IIS server.
When configuring the app, customize the folder wwwroot
you copied.
Now you need to unlock the section system.webServer/handlers
, which can be found in the IIS manager on the server node under the section Configuration Editor
. Find the section you want and open it from the right action pane.
Make sure the application pool is set to No Managed Code
. DNX starts as an external process. IIS doesn't have to know that it is currently running.
Finally, create web.config
with the following content:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
It should work at this point.
source to share