i'm having a bit of a weird problem.
I programmed a asp.net mvc app and runned locally at http://localhost:1234/ it works fine.
i have a route for /employee and this route kicks in.
But when i move it to my webserver at http://myapp.mydomain.nl (it is at a subdomain 'myapp') the /employee route doesn't kick in (i get a 404).
i have installed the RouteDebug.RouteDebugger component and normally it shows you the yellow and white page to show you which route kicks in, and if you type an invalid uri you see that no route kicks in. But now it doesn't show me this page, but just a 404, so it looks that the mvc doesn't 'kick in' when i navigate to http://myapp.mydomain.nl/employee, but my server treats my request as a normal request so it loos for the nonexisting folder 'employee'.
It is on a server that has not the mvc framework installed so i manually copied the System.Web.Mvc.dll to the bin folder.
Michel
You will need ASP.NET MVC installed and also setup the wildcard mappings to be able to view MVC routes properly (if using IIS5/6).
Here's a link to setting up ASP.NET MVC with IIS 5 and 6.
http://blogs.microsoft.co.il/blogs/dorony/archive/2007/12/15/using-asp-net-mvc-on-iis-5.aspx
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
Related
I'm trying to deploy a MVC 3 site to IIS 7.5. The deafult route works but all links return a 404 error including if I manually enter the link for the homepage.
Details:
MVC 3 to IIS 7.5
Windows Server 2008 R2
MVC 3 is installed on server
Default Web Site/PaedPhysiotherapy_Uat
.net 4 is installed
DeafultApplicationPool used
App pool is .net4 and running in integrated mode
Custom error are turned off
If I deploy to a new website on the same IIS box using different ports, e.g. "http://newsite:81 which not under the default website everything works fine.
Even in the absence of routing, IIS will redirect requests for "/" to "/Default.aspx". In an MVC app, there's a Default.aspx which manually finds the MVC handler and invokes it. So that's probably why your home link works.
Your other pages must go through routing. In integrated mode there must be an IIS handler for this. Check the ExtensionlessUrlHandler in the IIS handler mappings. Compare that and other handlers with the sites which work.
At a guess, if this works when deploying to the root of a site then it looks like an absolute path has sneaked in. Perhaps somewhere this is a missing ~ in front of a path e.g.
/MyController
instead of
~/MyController
Also, you did remember to convert /PaedPhysiotherapy_Uat to an application?
What is the Default.aspx page for in an MVC app? Does this actually execute? Does this page have anything to do with the "Default" route in the global.asax?
If you take a look at the comments at the top of Default.aspx
Please do not delete this file. It is
used to ensure that ASP.NET MVC is
activated by IIS when a user makes a
"/" request to the server.
Basically, it acts as an override for the possibility of a different default page being loaded by IIS. In IIS6 if you have an index.html in the same directory as your MVC application, it can sometimes render that file instead of looking for the default blank route in your application. Default.aspx prevents that from happening.
I am trying an sample application in Asp.Net MVC 2 Application
given in http://www.codeproject.com/KB/aspnet/aspnet_mvc_tutorial.aspx
But i am getting the error as below
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/PersonalInformation/Index.aspx
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Please let mw know wat is the problem
The problem is the requested url. In an ASP.NET MVC application, the url corresponds to a controller action instead of the aspx page. See this link for an explanation: http://www.asp.net/LEARN/mvc/tutorial-02-cs.aspx.
The url should be something like http://localhost:xxxx/PersonalInformation (where xxxx is your port number)
To avoid getting this error everytime you start up your website through Visual Studio. Go to the properties of your web project and under the Web tab there is a property called Start URL. Change this to http://localhost:xxxx/ or something that is a valid MVC route.
Are you deploying to Cassini or IIS 6. Take a look at these articles
http://guyellisrocks.com/coding/deployed-asp-net-mvc-app-gives-404-on-about-page/
http://www.techdreams.org/microsoft/aspnet/how-to-fix-404-errors-of-aspnet-mvc-website-deployed-on-iis-6-windows-server-2003/2572-20090515
MVC runs fine in Cassini but requires some config modifications to run in IIS. I am still evaluating it in Cassini so i havent crossed that bridge yet but this info should help.
I just installed the ASP.Net MVC Preview 2 so I can have a look at some of the new features.
However when I create a new MVC 2 project it creates everything but default.aspx, is this a bug or is this handled differently in version 2 to version 1? When I run the project it just takes me to the directory listing, I assume I could just copy one from an MVC 1 project?
Edit
Just to update, if I add a default.aspx to the project with the following line in its page load then the application works fine
Response.Redirect("Home/Index");
It's just the initial route request that doesn't seem to go through the routing engine. This is when I'm running it from visual studio, I haven't yet tried deploying to IIS.
Have updated to the latest version of ASP.Net MVC 2 and the problem went a way. So I guess either something went wrong with my install or there was a problem with that version
You don't use Default.aspx for MVC. There is no 1 to 1 mapping of URLs to files.
It is not supposed to be there in ASP.NET MVC 2, you might want to check your default routes though.
Default.aspx is typically the default page out of the box in IIS and will conflict if not override your routing in MVC. If you need a "default" page use "Index.aspx."
Out of the box /Home/Index is the default page/route, of course you can change this in the Global.asax
i have an asp.net mvc website. http:/mywebsite.com (just for this example)
I have been testing this asp.net mvc website locally on my machine and everything works fine on my local machine during testing. When i deploy to my web server
when i bring up http://mywebsite.com it goes to HomeController and load the view Views/Home/Index.aspx (which is perfect). So the main default page is fine.
The issue is, if i click any other other links (again that all seem to work fine locally) i get the following error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Please try the following:
* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
* If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
* Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
some examples would be:
http:/mywebsite.com\Photos
http:/mywebsite.com\Links
there definitely are controllers and views setup for this (or it wouldn't work locally).
does anyone have any idea how this might work fine locally but somehow on the webserver it doesn't
Are you running the site on II7 in integrated mode? If not, you need to add a wildcard handler so that all URLs get mapped to your application. See Phil Haack's blog post on running ASP.NET MVC ON IIS 6.
Something else to watch out for. I had a static website - deployed on IIS 7.5. Added some MVC Controllers to handle some simple server side apps and then re-deployed it. I didn't copy the web.config file, because I wrongly assumed that everything that was needed was in the one that was automatically created by the server.
You must copy the web.config up as well.