On app startup, before logon, I want a few 'pages', which live the same folder as my logon page to be okay to goto.
IN old aspx land you dropped a web.config in the folder where those pages lived and did this:
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
What is the correct way to do this in MVC land? I tried not puting the [Authorize] tag on the controller methods I wanted to be accessable but that does not seem to cut it.
Interesting new evidence...
I went to my web.config
I changed this:
<authorization>
<deny users="?" />
<allow users="*" />
<deny users="*" verbs="OPTIONS, PROPFIND, HEAD" />
</authorization>
to:
<authorization>
<allow users="*" />
</authorization>
and now if I type this path:
http://localhost/StudentPortal3G/Account/ChangePasswordSelfService
it works,
But if I type this path :
http://localhost/StudentPortal3G/Account.mvc.aspx/ChangePasswordSelfService
it does not (and this is the path generated by Atml.ActionLink(...))
I figure this has to be a clue, and I supect my Routing is to fault, but I'm not seeing it.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.css/{*pathInfo}");
routes.IgnoreRoute ( "{resource}.jpg/{*pathInfo}" );
routes.IgnoreRoute ( "{resource}.jpg" );
routes.IgnoreRoute ( "{resource}.gif/{*pathInfo}" );
RouteTable.Routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "Assets" });
RouteTable.Routes.IgnoreRoute ( "{folder}/{*pathInfo}", new { folder = "Images" } );
routes.IgnoreRoute ( "{*favicon}", new
{
favicon = @"(.*/)?favicon.ico(/.*)?"
} );
routes.IgnoreRoute("elmah.axd");
//routes.MapRoute("About", "Home/About", new { controller = "Home", action = "About", id = "" });
// you have to add this IgnoreRoute so that the PDFX pages get handled like a regular *.aspx page, not a MVC page. - EWB
routes.IgnoreRoute("{resource}.pdfx");
// allow MVC to run on IIS 5,6,7
//http://stackoverflow.com/questions/57712/mvc-net-and-iis-5
routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller = "Email" }) });
routes.MapRoute(
"Email", // Route name
"{controller}/{action}/{id}", // URL with parameters
null // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"Default2", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults );
);
routes.MapRoute(
"Default3", // Route name
"{controller}.mvc.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults );
);
}
More Info: if I comment these out, the HTML.ActionLink starts generating the link that works.
routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller = "Email" }) });
routes.MapRoute(
"Default2", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults );
);
routes.MapRoute(
"Default3", // Route name
"{controller}.mvc.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults );
);
Then if I put back this one(Which is required to work on server 2008 I beleive):
routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller = "Email" }) });
it starts to fail again...
Does anyone have any ideas?
Any Help is appreciated.