In my infinite wisdom, I've decided to implement the mobile version of a site using a mobile template called "m". All mobile requests are thus the same as the desktop site, but with /m appended to it. (I'm doing some mobile device detection, etc, but thats not really relevant to the problem at hand).
I have protected content on the site. In Umbraco, the content manager chooses the login page to use for unauthenticated users, e.g. /login. I need to be able to override the url that unauthenticated users are bounced to, say from /login/ to /login/m/. However, I'm at a loss as to where I can do this. I already have a custom membership provider on the site that works nicely, but I can't see any methods in there that would help.
Any ideas? Hopefully I've been clear in describing the issue.
You could maybe add some code to the login template to redirect to login/m if the user is on a mobile device?
It is actually possible to override the template on the master page if you want (rather than redirect to /m). If you hook into the oninit function of the default.aspx page you can override the template. If you put the following code on the default.aspx file of your Umbraco site you'll be sorted.
You could probably tidy this up to make it more efficient, but you should get the idea!
I've just had to set up over 50 rules for a site I migrated; I didn't use the internal config but went with the IIS UrlRewriter plugin and set up a linked config with them all in there.
Aw man that is fantastic! Thanks Tim. A very elegant solution to many of the problems I've had, just wish I'd known about this a week ago :) Now to rip out some http handlers...!
Tim's solution works perfectly in every situation except one. For some reason, on my staging server, I get the IIS standard 404 page for the mobile site. It works fine on my local machine (doesn't it always?)
I've checked:
umbracoSettings.config
404handlers.config
web.config
ID of page being requested
And it all looks fine, same as my local version. But for some reason when changing the master template in code for mobile 404 page, it ends up serving the IIS default 404 page instead.
In umbracoSettings.config is there a "tryskipiiserrors" setting (can't remember when this was introduced)? If there is, set that to true (you'll need to kick the app pool afterwards I think).
If that's not there, you need to add to the system.webserver part of the web.config.
Brilliant, thanks Tim. Beers definitely on me next time I see you. Bit weird that I didn't need to do that on my machine but I'm not complaining. All in all a very neat solution, hell of a lot better than I had yesterday, and much easier to maintain as well. #h5yr
override login page url for protected content
Hi all,
In my infinite wisdom, I've decided to implement the mobile version of a site using a mobile template called "m". All mobile requests are thus the same as the desktop site, but with /m appended to it. (I'm doing some mobile device detection, etc, but thats not really relevant to the problem at hand).
I have protected content on the site. In Umbraco, the content manager chooses the login page to use for unauthenticated users, e.g. /login. I need to be able to override the url that unauthenticated users are bounced to, say from /login/ to /login/m/. However, I'm at a loss as to where I can do this. I already have a custom membership provider on the site that works nicely, but I can't see any methods in there that would help.
Any ideas? Hopefully I've been clear in describing the issue.
Thanks!
David
It might help to mention I'm running Umbraco v4.11.8, non-MVC. Thanks!
You could maybe add some code to the login template to redirect to login/m if the user is on a mobile device?
It is actually possible to override the template on the master page if you want (rather than redirect to /m). If you hook into the oninit function of the default.aspx page you can override the template. If you put the following code on the default.aspx file of your Umbraco site you'll be sorted.
You could probably tidy this up to make it more efficient, but you should get the idea!
:)
David, These links might help you:
Umbraco Config Files
URL Rewrite issue
Add a Url Rewrite rule
I've just had to set up over 50 rules for a site I migrated; I didn't use the internal config but went with the IIS UrlRewriter plugin and set up a linked config with them all in there.
Using the URL Rewrite Module
Creating Rewrite Rules for the URL Rewrite Module
IIS7 urlrewrite module - Rules in external xml file
Aw man that is fantastic! Thanks Tim. A very elegant solution to many of the problems I've had, just wish I'd known about this a week ago :) Now to rip out some http handlers...!
Hi Jon,
Thanks for that, I'd tried using url rewriting as well, but I think Tim has nailed a very elegant solution here.
Cheers,
David
Hi all,
Tim's solution works perfectly in every situation except one. For some reason, on my staging server, I get the IIS standard 404 page for the mobile site. It works fine on my local machine (doesn't it always?) I've checked:
And it all looks fine, same as my local version. But for some reason when changing the master template in code for mobile 404 page, it ends up serving the IIS default 404 page instead.
Any ideas on what to check?
Thanks,
David
In umbracoSettings.config is there a "tryskipiiserrors" setting (can't remember when this was introduced)? If there is, set that to true (you'll need to kick the app pool afterwards I think).
If that's not there, you need to add to the system.webserver part of the web.config.
:)
Brilliant, thanks Tim. Beers definitely on me next time I see you. Bit weird that I didn't need to do that on my machine but I'm not complaining. All in all a very neat solution, hell of a lot better than I had yesterday, and much easier to maintain as well. #h5yr
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.