开发者

redirect to route result resource not found

i have an action filter which implements a basic check to see if the user is authenticated.

if the user is not authenticated i've implemented this:

        var routeValue = new RouteValueDictionary
     开发者_如何学C                        {                                     
                                 {"Controller", "Permission"},
                                 {"Action", "NoAccess"}
                             };

        filterContext.Result = new RedirectToRouteResult(routeValue);

        base.OnActionExecuting(filterContext);

ok this works and points the user to:

http://localhost:/Permission/NoAccess

but the problem starts to happen when i reload my project and the user is then redirected to:

http://localhost:/Views/Permission/NoAccess.aspx

and i get the error: The resource cannot be found.

slightly confused why it works once then breaks again after a reload? any suggestions?maybe i should be redirecting using another method?

using IIS express, visual studio 2010, MVC2


This looks like an unfortunate feature of Visual Studio...

If you have the view NoAccess.aspx open in Visual Studio and then press F5, Visual Studio opens the Internet Explorer with the URL http:/localhost:11111/Views/Permission/NoAccess.aspx. This URL might work for a classic ASP.NET application, but it doesn't for ASP.NET MVC applications. And it's basically a bug in Visual Studio and certainly not in your application.

If you open a .cs file and then press F5, Visual Studio will start Internet Explorer with the URL http:/localhost:11111/.

I'm not sure this applies to your problem because I don't know what you mean by reload your project. But it might be what your seeing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜