开发者

ASP.Net MVC 2: My controller actions are not being called

I'm not sure what happend but suddenly my controller actions are not being called. This project has been working fine all day, but now when I run it (in Cassini or IIS 7 ) I get "Internet Explorer cannot display the webpage". No server error, not even 404 or 500 error.

In stepping through the code I can see that the routes are registered properly during application start up. The contstructor and Initialize method are called on the correct controller then.....nothing. I was able to inspect the requestContext coming into the Initialize method on my controller and the framework has picked up the correct Route Data. This happens with all my controllers. Another MVC project runs just fine on the same machine.

I'm completely lost. Any help will be GREATLY appreciated as I have a deadline of Dec 1st on this project.

Thanks, Jeff French

Here's some of my code:

My home controller which doesn't work:

public class HomeController : Controller
{
    public HomeController():base()
    {

    }

    protected override void OnException(ExceptionContext filterContext)
    {
        base.OnException(filterContext);
    }

    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        base.OnActionExecuting(filterContext);
    }

    protected override void Initialize(System.Web.Routing.RequestContext requestContext)
    {
        base.Initialize(requestContext);
    }

    protected override void HandleUnknownAction(string actionName)
    {
        base.HandleUnknownAction(actionName);
    }

    public ActionResult Index()
    {
        //if (!Request.IsAuthenticated)
        //    return RedirectToAction("LogOn", "Account");
        return View();
    }

    public ActionResult About()
    {
        return View();
    }
}

I added the overrides so that I could set breakpoints in them to see what was being called. The contructor is called then the Initialize method. The requestContext passed to the Initialize method contains the correct route data. As soon as the Initailize method finishes executing I get the "Inte开发者_开发技巧rnet Explorer cannot display the webpage" message.

My Glogal.asax:

public class MvcApplication : HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{tenant}/{controller}/{action}/{id}", // URL with parameters
            new {tenant = "demo", controller = "Home", action = "Index", id = ""} // Parameter defaults
            );
    }

    public void RegisterViewEngines(ViewEngineCollection engines)
    {
    }

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
    }


    protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
        RegisterViewEngines(ViewEngines.Engines);
    }
}


Well, I've solved my problem and as it turns out it has nothing to do with MVC or my code, really. An inspection of the System Event Log revealed a series of SSL errors on my local machine. The controllers in my project were decorated with the [RequreHttps] attribute since I need this site to be served via SSL. The self signed cert has been working fine for testing on my local machine, but suddenly it is not. However, that is a completely seperate issue and, if necessary, I will post it as a seperate question. Thanks to all those who looked into this problem, I appreciate your time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜