I'm using asp.net MVC on IIS 7 / windows 2008 server.
The problem is that asp.net mvc generates urls with no slash at the end, like: http://site.com/category/asp. When this url is clicked, IIS 7 probably thinks its a directory and issues a 302 redirect to http://site.com/category/asp/ (with the end slash). How do i change this? I do not want an extra redirect overheat. This does not happen on the Visual Studio web server. Also doesn't happen on nerddinner.com.
You can probably use URL rewriting in IIS7 to help here. Take a look at the article that Scott Hanselman wrote on the issue:
http://www.hanselman.com/blog/ASPNETMVCAndTheNewIIS7RewriteModule.aspx
I think this is not the way, since the web server on Visual Studio doesn't use rewriting and the urls works there with no 302 redirect. Also, i don't think nerddinner.com is using IIS rewrite..
thanks
Related
My ASP.NET MVC site needs to be running in either IIS6 or IIS7, I need to a url with a suffix of ".mvc" when its running in IIS6.
I know I could add an AppSetting but is there away to know if the site is running in IIS6(IIS7 classic mode) or IIS7?
You do not need to have an extension for MVC on IIS unless you are using MVC1. MVC2 and up work just fine with extensionless URLs on IIS6.
However, to answer your question, check out this previous question: How to detect IIS version using C#?
You can check the http response header from the client side with a browser developer tool (F12).
I've built an ASP.Net MVC 2.0 site in VS2010, targeting .Net 3.5.
I'm trying to 'bin deploy' to a server running IIS 6.0.
The server is a 'test' virtual server running Windows Server 2003 R2 64bit, and .Net 2.5 SP1.
MVC has not been installed on this server.
I am trying to replicate the hosting environment where this application will be deployed for production.
The issue I'm having is every page I try to browse to shows a 404.
I've tried adding .mvc and .aspx to the routes in the Global.asax.cs file, but it seems to make no difference.
I've also created a Default.aspx page which redirects to the Home.aspx (or Home.mvc) URL.
Nothing seems to work.
I've been browsing the web for hours searching for an answer, and still nothing works.
Any ideas?
Edit
Wow, I feel like a right idiot now... :) Turns out that ASP.Net wasn't registered properly so the ASP.Net v2 extensions were still disabled on the IIS6 server.
I guess small things like this get past when you've only worked with Server 2008 and IIS7 for the last year or 2...
So I'll mark this as 'Answered / closed'...
Turns out that ASP.Net wasn't registered properly so the ASP.Net v2 extensions were still disabled on the IIS6 server. I guess small things like this get past when you've only worked with Server 2008 and IIS7 for the last year or 2...
I have an MVC 1.0 app just setup but it only shows the Index.aspx page
of Home.
Seems like the routing engine is not being engaged.
I get a 404 error when i try to browse other pages.
Any ideas why this might be?
Malcolm
It's probably that the ASP.NET DLL isn't being called for your request. If you are talking about IIS, Phil Haack has a great article on how to sort it out. Note: Scroll down for .* version :)
Essentially, you are telling IIS that for every extension, it should look use the .NET DLL to run it, but don't check to see if the file exists first (because in MVC, the files don't exist).
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?
I have started a new mvc project and clicked on project\properties\web - use local IIS server (mine is 5.1). I've created a virtual directory all ok.
When I run I get a 403 error - in url http://localhost/myProjectName/
I have set IIS to windows integrated security and set web.config to windows.
My ultimate goal is to use mixed windows and forms authentication for an intranet app.
I appreciate any help.
I don't believe this will work off the bat for IIS 5.1. By default, MVC controllers/pages don't have extensions, and so IIS doesn't know who to forward the request to during the request pipeline.
In IIS 6.0, you can set a IIS wildcard mapping forward all unknown files to the ASP.NET engine. For 5.1, you'll probably have to configure MapRoutes so that your urls include the mvc extension:
http://localhost/myproject/home.mvc
It can work. Solution is not elegant but it does exist.
Take a look at my article IIS vs. ASP.NET URL Rewriting