Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using friendlyurl in my asp.net website for hiding .aspx extension. but it came with mobile viewswitcher feature. and because of this on mobile it give error. So i simply want to do not use mobile feature. what should i do.

What I have tried:

use of Friendlyurl in asp.net website
Posted
Updated 8-Jul-16 10:36am
v2
Comments
Suvendu Shekhar Giri 8-Jul-16 13:11pm    
Just delete the Site.Mobile.Master page and it should work as you expect.
Kishor-KW 8-Jul-16 13:53pm    
ya i did that. but not working same error is occured.

The relative virtual path error is: MasterPage1.Mobile.Master is not allowed here
Freelancer sekhar Babu 8-Jul-16 14:15pm    
plz check the link same case was discussed and answered there. http://forums.asp.net/t/2054029.aspx?Disable+Mobile+View+Switcher
Kishor-KW 8-Jul-16 15:26pm    
thank you it's help. plz add this to solution

1 solution

Step 1, define a class Inherited from WebFormsFriendlyUrlResolver and override TrySetMobileMasterPage method, Code below is for your reference.
C#
public class MyWebFormsFriendlyUrlResolver : Microsoft.AspNet.FriendlyUrls.Resolvers.WebFormsFriendlyUrlResolver
{
    protected override bool TrySetMobileMasterPage(HttpContextBase httpContext, Page page, String mobileSuffix)
    {
        if (mobileSuffix == "Mobile")
        {
            return false;
        }
        else
        {
            return base.TrySetMobileMasterPage(httpContext, page, mobileSuffix);
        }
    }
}

Then update the RegisterRoutes method.

C#
public static void RegisterRoutes(RouteCollection routes)
{
    var settings = new FriendlyUrlSettings();
    settings.AutoRedirectMode = RedirectMode.Permanent;
    routes.EnableFriendlyUrls(settings, new MyWebFormsFriendlyUrlResolver());
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900