开发者

ASP.NET MVC Routes Login/Logout Problem

开发者 https://www.devze.com 2022-12-20 10:26 出处:网络
Relatively new to ASP.NET MVC and little confused about how to do routing. My problem basically relates to \"logged in\" and \"logged out routes\" and having both as \"/\".

Relatively new to ASP.NET MVC and little confused about how to do routing. My problem basically relates to "logged in" and "logged out routes" and having both as "/".

i.e. I have home/index for logged out user which appears as "/" but this has got me confused as to how I can have home/home for logged i开发者_开发知识库n user and still have "/".

I keep getting 127.0.0.1/home/home

I could modify like 127.0.0.1/home - but I want it like "/". My confusion relates to the fact that the "/" [127.0.0.1/] is bound in the routes collection to home/index.

Does anyone know how I can modify the routes dictionary (which will be binded ONCE at the start) so that the "/" can be shared for logged and non-logged users ?

Thanks?


Ideally each route should point to a distinct view, so if there's slightly varying functionality on that view for logged in users vs. logged out users, you should drive the difference in your view logic and not in routing. If you have significant chunks of HTML that would be different, consider exploring the Html.RenderAction method.

0

精彩评论

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

关注公众号