سؤال

I'd like to achieve the MVC View Engine behavior in an web forms application. To register a mobile channel in MVC I normally would do something like this

public static List<string> UaSurfpads = new List<string>()
{
    "iPad",
    "MicrosoftRt",
    "PlayBook"
};    

protected void Application_Start(object sender, EventArgs e)
{
    // register surfpads
    foreach (string device in UaSurfpads)
    {
        DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile")
        {
            ContextCondition = (context => context != null && context.GetOverriddenUserAgent().IndexOf(device, StringComparison.OrdinalIgnoreCase) >= 0)
        });
    }

    // ...

}

This will enable me to create shadow views like myView.mobile.cshtml.

Is there any similar way to work using regular web forms in asp.net?

هل كانت مفيدة؟

المحلول

ASP.NET WebForm also have mobile features, as well as MVC. Just read this article Also, official MS web source for mobile development

نصائح أخرى

There is nothing native live MVC to handle this. However, you can achieve this by putting some code in your app to detect and redirect. 51 degrees used this approach and created a freely available framework to do all of this. I'd recommend looking at it, or at least how they achieve their mobile implementation, and mimic it for your site.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top