3

Every time I run a certain application it is showing a Not Found erroralt text

Does anyone know how to resolve this?

I placed a debugger on the page_load event in the default.aspx.cs file but it is not getting called.

Below is the routing configuration:

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // parameters
            new { controller = "Home", action = "Index", id = "" }  // Parametedefaults
        );

I tried everything I can think of, but it is not working.

dove
  • 20,469
  • 14
  • 82
  • 108
Niraj Choubey
  • 3,942
  • 18
  • 58
  • 93

6 Answers6

0

What web server are you running this on VS Dev/Cassini? IIS? See if you have a default.aspx in the root folder. You need a dummy root default.aspx for MVC to work properly with some webservers.

UpTheCreek
  • 31,444
  • 34
  • 152
  • 221
0

If you are using IIS 6 you will need a wild card mapping to the aspnet isapi filter if you are using urls without an extension. There are other options such as using a fake extension e.g. mvc and mapping through to that. By default IIS 6 doesn't know to treat pages without extensions as asp.net

Steve Sanderson gives an excellent article about deploying to IIS 6 (http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/).

Of course if you are using IIS7 then it should just work out of the box. In that case I don't know.

Crab Bucket
  • 6,219
  • 8
  • 38
  • 73
  • This post gives a full list of comments about deploying onto IIS 5.1 http://stackoverflow.com/questions/301359/deploy-asp-net-mvc-on-iis-5-1-windows-xp. It is a bit faffy – Crab Bucket Dec 24 '10 at 13:19
0

If you have all the things in their places then it seems like either:

  • The routes are configured incorrectly. Most likely you don't have proper default values for your Controller/Action.
  • You are using older IIS versions and they're not configured properly. See this for instructions.
Vasiliy R
  • 941
  • 8
  • 18
0

Try to check your Default.aspx code as below:

using System.Web;
using System.Web.Mvc;
using System.Web.UI;

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, System.EventArgs e)
    {
        HttpContext.Current.RewritePath(Request.ApplicationPath, false);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current);
    }
}

and you need to configure your iis's wildcard mapping, see below: http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx

Tee Wu
  • 569
  • 2
  • 9
0

From the looks of it you don't have a default route set up. Try this:

Routes.MapRoute("Site (*)", "{action}", new {
    controller = "Site",
    action = "Default"
});

This basically sets up a root route which defaults the action to "Default" if nothing is passed in. This also maps to all root routes such as /Home, /Contact, /{Whatever}.

Gup3rSuR4c
  • 9,145
  • 10
  • 68
  • 126
0

as per comments in question I placed debugger on page_load event in default.aspx.cs file but it is not getting called. Below is the routing configuration:

  • have you tried to set your default.aspx as StartUp Page for your project.

and same in IIS virtual directory.

swapneel
  • 3,061
  • 1
  • 25
  • 32