I deployed an ASP.NET MVC 4 project to my testing server, but it does not seem to run.
Attempting to access the project URL on IIS 7 after deployment attempts to list the directory contents. Checking the folders reveals that all assemblies have been deployed. Enabling directory browsing actually lists the files in the directory and can serve static files.
It's as if my .NET 4.0 application pool is not routing any requests to the controllers.
What could be causing this?
Solution
Found the solution out of sheer luck, which is setting runAllManagedModulesForAllRequests to true in web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
...
</system.webServer>
I had this exact problem the other day when starting a new project on a new machine. Then I found this question and all of my wildest dreams came true.
Related
Application Insight is not displaying the server requests data in Azure Application Insight dashboard. During live streaming I have faced the below error.
Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer fail with FileNotFoundException on loading Microsoft.AspNet.TelemetryCorrelation, Version 1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
Any idea, how to fix ?
I had the same problem and install it with the nuget package manager and browse Microsoft.AspNet.TelemetryCorrelation and installed it
I recently came across this issue when adding App Insight in our web application hosted on Azure Cloud Service (Classic). First i did have to manually add the nuget package Microsoft.AspNet.TelemetryCorrelation as it was not added automatically when i configured the Application Insight. This was not enough i had to make the change in the webconfig file and included integrateMode in the preCondition for the TelemetryCorrelation so it looks like this <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />. When we configure Application Insight it automatically adds this module but with only managedHandler as preCondidition which doesn't work for me.
Navigating to 127.0.0.1/rails spawns ruby.exe when looking through the Process Explorer, they quickly disappear and the page never loads. Leads me to believe that there is something wrong with my config file.
I am following along with Running Ruby on Rails on IIS8 with HttpPlatformHandler and I hit a wall.
I have verified that Rails can run a application under the local WEBrick server. However, I cannot figure out why a application will not launch under IIS8. I am hoping someone out there can help me verify a few things or point me in the right direction. In the blog, Scott is running Windows 8. So, perhaps there are some differences that I am missing by using Windows Server 2012.
Windows Features
In the blog, Scott simply turns Internet Information Services on. On the server, it seems a bit more involved. I have installed:
Application Server:
.NET Framework 4.5
Web Server (IIS) Support
Web Server (IIS)
Web Server
Common HTTP Features
Application Development
Perhaps someone out there could verify that I am not missing anything in that section. I can elaborate further if necessary.
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile="rails.log" startupTimeLimit="20" processPath="c:\Ruby22-x64\bin\ruby.exe"
arguments=""C:\Ruby22-x64\bin\rails" server -p %HTTP_PLATFORM_PORT% -b 127.0.0.1">
</httpPlatform>
</system.webServer>
</configuration>
Thank you for taking a look! Any input would be very much appreciated! I realize serving a Rails application on Windows is not ideal. However, I am not left with any other choice...
I believe that my original problem boiled down to user account control issues. But that was taking to long to get resolved, so I took a different path.
I ended up using Apache. This answer to this question was very helpful.
Rough outline of steps I took:
Install Ruby, DevKit, Rails and make sure they run
Make sure your application can run locally
Create .bat files that start your server. Convert them to .exe's. Then create a service start them with nssm.
Setup and configure Apache
Edit your httpd.conf file
Make sure you have the necessary modules installed. You can use Apache error logs to troubleshoot this step.
Include vhosts if you opt to use that.
Edit vhosts file so it points to your application.
In Visual Studio my project builds and runs with no problem. When deploying to Windows Server 2012 R2 I encounter the following error:
A default document is not configured for the requested URL, and
directory browsing is not enabled on the server.
I have installed all 4.5 and other Roles and Profiles, have given permission to the folder to everyone and have read every article and tried to implement every suggestion to no avail..
I'm out of options, spent weeks on this and cannot understand how this is so convoluted just to deploy a site.. Can someone advise? Thanks
Edit - this is for Windows Server 2012 and I have tried suggested alternatives such as adding runAllManagedModulesForAllRequests to my web.config.
Edit When deploying I build the solution in Release mode and copy the bin, views, content and scripts folders over to Windows Server. In IIS I then make the folder an application, making sure a 4.0 App Pool is assigned and still receive the error.
Final Edit
Publish allowed me to see the structure that needed to be copied over. There were also 3 dll's that needed to be copied local from Visual Studio:
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Net.Http.Formatting.dll
As well as Web.Config dependentAssembly updated to take into account some MVC4 dll's such as Unity.Mvc4 pointing to MVC3 binaries.
This error message gives a clue as to the problem. MVC sites do not rely on documents or web pages in the way that WebForms do, the default mode for IIS. They depend on a special handler that deals with the RESTful urls used to pass requests to your application.
In your web.config file, check that the following config is present in the system.webServer section:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Then on your web server, open the IIS Manager, navigate in the Connections panel on the LHS to the node that represents your application, then double-click on the Handler Mappings icon in the Features View tab. Check that the ExtensionlessUrlHandler-Integrated-4.0 handler is enabled (see below).
If that doesn't do the trick, double-check that you have the ASP.NET 4.5 Role enabled on the server. See http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45#TOC301258515 for instructions.
Also make sure you application is running under an AppPool that is configured for .NET 4.0.
I recommend you to use Publish Tool in Visual Studio by right clicking on project in solution explorer to deploy resultant files on the web. Then try the followings:
Reinstall .Net framework and MVC using Web PI.
Put a dummy default.aspx file in the root folder (this will not be
used when MVC is working, but can get rid of this problem).
Try running the aspnet_regiis -i command in the Visual Studio 64
bit command prompt (with admin privileges), then deploy it.
Take a look at Default Document configuration in IIS.
I wish to be solved.
Seems like IIS has not considered your application as a web application. It must be a MVC version mismatch.
As it is tagged as MVC4, we have 3 inner versions in MVC4. Check the server for which version of MVC is installed.If it is not installed or if you dont want to install MVC in the server, set CopyLocal=true for all the assemblies that you have referred in your project and re-publish the application and deploy in the server.
My work has some dedicated web servers (Server 2008R2, IIS7). Currently everything done here before has just been asp.net webforms. For a new project I want to finally introduce them to MVC. I have a vanilla MVC application created in VS2013. I walked through some different sites and got it set up on my local IIS (full, not express) just fine. I can hit 'localhost' and see the site I created. I am using web deploy, and it worked very well.
After that I moved on to our development server. I set it all up the same (i.e new website in iis, web deploy set up with proper credentials, etc). Publishing from VS works. On the development server I see all the files there, but in IIS on the server (via RDP session) I cannot browse to it. It does not give me a 404 or 503 error, internet explorer just tells me that it can't find the address.
Based off the many, many articles I went through I did the following:
aspnet_regiis.exe -i (32 and 64 bit)
Made sure the server has Web Deploy 3.5 and Web Deploy tools 2.1 installed.
Added some lines to my web.config (see below)****.
made sure the server had .net 4.5 and mvc installed.
After all that it still will not show me the site. Anything I am missing? I would love to find a tutorial to walk me through baby-step by baby-step, but all I see out there assumes that you already have x and y set up, or you already know IIS like the back of your hand.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
To deploy MVC4 Application onto IIS 7.5
Make sure that you installed the latest framework.
Go to %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe –ir for 32 bit or
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –ir for 64 to register asp.net
To be able to work with sites in MVC for IIS7 ir IIS7.5 please update it (http://support.microsoft.com/kb/980368).(Good)
Make sure that there is:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule"
preCondition="" />
<!-- any other modules you want to run in MVC
e.g. FormsAuthentication, Roles etc. -->
</modules>
in web.config. (Good)
Make sure that there is
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
in web.config.(Bad)
from own experience... use "Good"
I have built an MVC 3 application and I have a Web Server 2008 on which IIS 7.5 is installed.
In IIS, I created a new Site and under which an Application then I deployed all my physical files on that application folder:
C:\inetpub\wwwroot\DeveloperToolsPortal\Application
I have also configured my Application Pool so that it supports .NET 4. I also downloaded the MVC3 on this server from the asp.net/mvc3 website.
When I browse this application from IIS using the {0} url, I get the {1} error message:
{0}: http://localhost:85/Application/Home/Index
{1}: HTTP 500 Internal Server Error
The Site was configured to use port 85 as 80 was already taken by another Site.
I've also added the below configurations in the web.config file:
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<customErrors mode="Off"/>
Why is this getting this error? How could I fix it? Which step/s have I missed in configuring my application?
I also tried another thing. I added a simple .htm file under my application and tried openning it via IIS and it gave me the below error:
Internet Explorer cannot display the webpage
I'd guess there is something wrong with my IIS?!
Don't put it in a subdirectory of C:\inetpub\wwwroot
The problem is that by default, there's a web.config file in C:\inetpub\wwwroot, which IIS will read from, even though your site is not directly in that directory.
You can create another folder in C:\inetpub and put your site into there.
Also, you can have multiple sites running with the same port, but using different host headers.
Out of curiosity, where did port 85 come from? Try taking that out (the default port for HTTP is 80). Also, look in the application error log for additional info on the error. There is also a section of web.config that you can set so that detailed error messages will be displayed (which should not be set for production).
<customErrors mode="Off">
</customErrors>
I added some more features/services to my IIS using the Server Manager and registered asp.net with it using aspnet_regiis -ir and this error is resolved.