Reputation: 3269
Reaching out to the community here for a best practice/best implementation question.
I am using MVC3 in a major project, the MVC3 site will handle both our full site as well as our mobile site in a single solution. I have created a custom view engine to handle mapping mobile requests to the appropriate mobile views.
A requirement that popped up recently is to have a "Full Site" link on the mobile portion of the site to allow a mobile user to view the full site (actually to be able to switch back and forth).
Anyone have any insight on a possible quick solution or done something similiar?
I have a separate layout file (master page) for my mobile views that the "Full Site" link appears on.
Thanks in advance for any possible answers.
Upvotes: 2
Views: 1466
Reputation: 16174
Maybe I'm misunderstanding your question, but if you're asking how to link the two "versions" of the site, wouldn't it be as "simple" as having two Areas
?
Each area will define its own routes, with the mobile area starting its routes with, for instance:
context.MapRoute(
"Mobile_Default",
"mobile/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
so it's quite easy to link from one area to the other:
@Html.ActionLink("non-mobile site", "index", "home", new { area = "" }, null)
and the other way round:
@Html.ActionLink("Mobile site", "index", "home", new { area = "mobile" }, null)
Upvotes: 0
Reputation: 8389
This should be something like a parameter for sure, view engine needs to know about the user preference. So it chooses the default view as it does now, but checks some parameter if the user preference does not match the default option.
Cookie, URL param...
Upvotes: 1
Reputation: 913
There are a few different ways you could go. A couple ideas:
Upvotes: 3