asp.net MVC 3 no default page - asp.net-mvc

Has anyone tried to deploy an asp.net mvc 3 website that uses the razor templates? The project does not create a default page and not sure if this changes in some way?

I have several projects in the pipeline that work on both IIS 7 and 6 (test servers) without any issues with a missing default.aspx page. I don't have any production code in effect but so far it's not an issue.
I would say the issue with a missing default.aspx page would rely on the server not using the <modules runAllManagedModulesForAllRequests="true" /> in the web.config. Otherwise a default.aspx page isn't necessary for handling. As long as IIS uses the mvc module to handle requests.

Related

ASP.NET MVC Sub Application

I have a ASP.NET MVC application at a root level (e.g. http://example.com), and have now deployed an additional ASP.NET MVC application as a sub-application (e.g. http://example.com/api). I have set the sub-application as an "Application" in IIS.
However, whenever I try to navigate to the sub-application, I am getting a 403.14 Forbidden error. It's like the sub-application isn't getting picked up as an ASP.NET MVC application. If I try and hit a url which has a controller/action method in the sub-application (e.g. http://example.com/api/home/index"), I get a 404 response.
In terms of setup, the only differences I can see in IIS Manager is a lack of an "ISAPI Filters" icon for the sub-application. I am running .NET 4.5, ASP.NET MVC 4, and IIS 7.5.
Does anyone have any suggestions on how to get this ASP.NET MVC sub-application working?
Turns out I was missing the following config from the <system.webServer> config in my child application:
<modules runAllManagedModulesForAllRequests="true"/>
After I put that in, it started recognising the child application as an ASP.NET MVC site.

Optimization Bundles and Umbraco 4

I've recently setup a hybrid Umbraco 4.8 webforms + mvc application (see aaron powell's post on this: http://www.aaron-powell.com/umbraco/using-mvc-in-umbraco-4)
I have everything working great. I even configured ninject and I'm using MVC4 optimization bundles. The problem is that when I try to enable optimizations the dynamic routes are getting picked up by the umbraco url rewriter and I can't render CSS or JS files in the release configuration.
This renders fine (since it's a static route):
http://myserverUrl/Scripts/jQuery/jquery.js
This doesn't:http://myserverUrl/js/combined?v=J_D8qmUMMTWvtIuuef2sskA8d2JCiGB9kNZMq_nNKpw1
Umbraco handles all the request, that aren't to a static file, so you need to configure Umbraco to skip those pathes
In web.config put "~/js" as a reserved url, just as you have done to the route you made.
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/js" />

Getting 404 error on MVC web-site

I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site deployed to it. The website was built in Visual Studio 2008, targeting .NET 3.5, and IIS 5.1 has been successfully configured to run it as well, for local testing.
However, whenever I try and navigate to a page running in IIS7, I get a 404 error.
I have checked the following things:
There is no corresponding 404 log entry in IIS logs.
Actually, there are 404 entries in the IIS log.
The application pool for the web-site is set to use the Integrated pipeline.
The "customErrors" mode is set to off.
.NET 3.5 SP1 is installed
ASP.NET MVC 2 is installed
I've used MVC Diagnostics to confirm all MVC DLLs are being found.
ASP.NET is enabled in IIS, which we've demonstrated by running the MVC Diagnostics page.
KB 2023146 did highlight that HTTP Redirection was off, so we've turned it on, but no joy.
EDIT
Ok, so we've installed the world's simplest MVC application (the one which is created when you create a new MVC2 project in Visual Studio), and we are still getting 404s on any page we try and access - e.g.
<my_server>/Home/About will generate a 404.
Any ideas will be greatly appreciated!
This is quite often caused by the following missing from the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
Do you have a problem with just 1 page or the whole site is not working?
A) 1 page
You can use RouteDebugger to verify if the route is matched correctly
B) Whole site
I assume you're using Windows Server - check if ASP.NET is enabled in IIS - it's disabled by default, I believe.
You can use MvcDiagnostics page to check if all dlls are deployed properly.
Are you running in IIS7 integrated mode? Classic mode of IIS7 does not automatically map extensionless URLs to ASP.NET (much like IIS6)
Make sure your Web.config tag is configured correctly.
We finally nailed this issue by exporting the IIS configuration of a working server, and comparing it to ours.
It was a really obscure setting which had been changed from the default.
IIS ROOT → request Filtering → Filename Extensions Tab → Edit Feature Settings → Allow unlisted file name extensions
This should be ticked.
This can be set at the IIS level, or the site-level.
Glad that fixed your problem. Others researching this issue should take note of the extensionless URL hotfix: http://support.microsoft.com/kb/980368
If none of the other solutions here solved your issue, check that you have the
Global.asax
file in your website. This solved the issue for me.
Checkout if KB 2023146 applies to your scenario. Also try requesting directly a controller action: /yoursitename/home/index
Apparently this can have many different causes.
For us, the problem was that the DNS entry was configured for two IP addresses, but the IIS configuration would only listen to one of them. So we got unpredictable results, sometimes it would work, sometimes a few files (css, etc) would not load, and sometimes the whole page would not load.
For me it was all about installing .NET Framework 4.6.1 on the server (my app was targeting that version)
You'll also get this if your bindings aren't correct. If you don't have www or a subdomain it'll return a 404.
I had this problem when running my MVC4 site with an app pool set to ASP.NET 4.0 and the Classic pipeline, even though the extension handlers were set in my web.config and were showing correctly in IIS. The site worked in Integrated Pipeline so I knew it was a configuration issue, but I couldn't nail it down. I finally found that ASP.NET 4 was disabled for the server in the ISAPI and CGI Restrictions settings. I enabled ASP.NET 4.0 and it worked.
In addition to checking if you're running in integrated pipeline mode, make sure your application pool is set to use .NET! I recently ran into this problem, and when I went in to check the app pool settings, I found that somehow it had been set to "No Managed Code." Whoops!
My Hosting company fixed this for me by doing this (I removed the original password value of course).
<system.webServer>
<security>
<authentication>
<anonymousAuthentication password="<password>" />
</authentication>
</security>
</system.webServer>
Typically I encounter this issue when there is a Routing problem. I compare a working vs non-working to resolve it.
Today however I accidentially created a Virtual Directory in IIS.
It has to be an Application, right click on the Virtual Directory (with a folder icon) -> Convert to Application:
Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.
<system.webServer> <!-- Rather do NOT use this -->
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Instead add the MVC routing module
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
</system.webServer>

Custom Errors not Forwarding on ASP.NET MVC Site

On my site, a broken link throws the default, page not found error. In the web.config I have turned on CustomErrors and forward 404 errors to a custom message.
On my dev box it works, on the host it does not.
Any ideas? ASP.NET MVC 1.0, SQL 2005, IIS 6 host (ya, I wish it was IIS7 - but they want to charge me to move the site).
Thanks in advance!
CustomErrors will only fire for files which .NET is actually assigned to handle. On your local Visual Studio this covers everything, but in IIS6 it only covers the files that are actually directly related to .NET (.aspx, .ashx, .asmx etc). This means that if you want it for everything you have to add an ISAPI filter to bind all files to be handled by .NET, which comes with overheads and can cause some unexpected behavior if you have any global handlers or HttpModules defined.
This page will help you with configuring a wildcard binding if that's the road you want to go down
Have you considered putting it in the IIS6 configuration instead of .NET? This may be simpler for you than trying to use the CustomErrors from .NET in IIS6.
As a sidenote IIS7 integrated pipeline mode does not have these issues and all files are handled by .NET by default.
It is possible a machine.conf setting is overwriting your web.config setting.
Have you contacted your host and asked them if they overwrite the CustomErrors tag?

ASP.NET MVC Application in Sharepoint 2007 virtual directory

I have MOSS 2007 installed at lets say http://localhost:4999/ and I want to have my custom ASP.NET MVC (1.0) application at http://localhost:4999/mvcapp/ - logic dictates that, in IIS, i should create a new application virtual directory under my MOSS site and point it at my custom MVC app.
I've done this and it works for executing my controllers etc, however, none of my /Content content is being returned! All referenced images, javascript and css aren't retrieved.
If I put this app into it's own site, or a virtual application within a non-sharepoint site, this works fine and pulls down the images, js and css as normal.
Note - I'm creating a new application in IIS, not just a virtual directory and I have no requirement for integrating with sharepoint, I just want it to have the same domain and port number.
Any ideas?
Cheers
Tony
** EDIT **
To clarify - the URL's that are being generated aren't the issue - they are correct and are being generated in the same way as they would be if this wasn't hosted under sharepoint. IE: /mvcapp/Content/Scripts/jquery.js etc.
** EDIT 2 **
More clarification - the MVC app has it's own web.config file - but it appears that when using a virtual directory withn a sharepoint site, many of the handler mappings still get pushed up to the child site (Note: This is a virtual directory configured as a seperate application not just a virtual directory).
Whilst I don't want or need SharePoint integration, I need my MVC app to come from the same domain and port to overcome some cross domain issues (a lot of MVC content is iframed into sharepoint in various ways). So sharepoint would be at http://site and my app at http://site/mvc
I would keep them on separate web sites (MVC and SharePoint that is). You could create a new website entirely for your MVC app, and then through IIS, right click your MVC web site, edit bindings, and redirect the traffic from your MVC website to URL you want.
I set up a couple of WebForms apps to run in much the same way you say that you want: a separate virtual application with its own web.config, etc. I had to tweak the web.config to make it work, though. My app uses things like session state and view state, but I reckon those aren't applicable to your MVC app. As I look at my web.confing, I think this section might be applicable for what you're trying to do:
<location>
<system.web>
<xhtmlConformance mode="Legacy" />
<trust level="Full" />
<httpModules>
<remove name="PublishingHttpModule" />
</httpModules>
</system.web>
</location>
Hope that helps. I also have an <authorization> section in there, but it wasn't necessary to make the app work.
Look at the following:
Configuring Specific Files and Subdirectories (MSDN)
Disabling Configuration Inheritance For ASP.NET Child Applications (Blog)
HTH

Resources