문제

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