BlazorWebFormsComponents icon indicating copy to clipboard operation
BlazorWebFormsComponents copied to clipboard

How do we handle Site.mobile.master and alternative rendering?

Open csharpfritz opened this issue 5 years ago • 4 comments

In the later versions of ASP.NET Web Forms, the concept of .mobile.aspx and .mobile.master pages were introduced to allow for alternative rendering of web forms that would target mobile browsers.

How should we handle this feature?

csharpfritz avatar Feb 17 '20 20:02 csharpfritz

It is possible to switch default layout, for example if you had a way of detecting mobile (there are lots of ways of course), you could just switch layout in the router

<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <RouteView RouteData=routeData DefaultLayout=Layout />
    </Found>
    <NotFound>
        <LayoutView Layout=Layout>
            <p>Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>
@code { 
    Type Layout;
    protected override void OnInitialized()
    {
        if (IsMobileDevice)
        {
            Layout = typeof(MobileLayout);
        } else
        {
            Layout = typeof(MainLayout);
        }
    }
}

Of course there are more complicated scenarios, such as using mobile but allowing the user to switch to desktop mode and back again, but the concept is still the same - just swap the default layout.

SQL-MisterMagoo avatar Feb 17 '20 23:02 SQL-MisterMagoo

I think we should provide that IsMobileDevice property to help with this

csharpfritz avatar Feb 18 '20 00:02 csharpfritz

I think that WebForms had some pretty comprehensive ways of detecting this - is any of that code open source / available to this project?

SQL-MisterMagoo avatar Feb 18 '20 00:02 SQL-MisterMagoo

That code should be available in the GitHub repository with the rest of ASP.NET. We should be able to lift it

There were also ways to detect using App_Browsers and some syntax in that folder. Its not something that we should want to maintain

Jeff

On Mon, Feb 17, 2020 at 7:26 PM SQL-MisterMagoo [email protected] wrote:

I think that WebForms had some pretty comprehensive ways of detecting this

  • is any of that code open source / available to this project?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FritzAndFriends/BlazorWebFormsComponents/issues/91?email_source=notifications&email_token=AAATF4P2OK4XEKR2G7EY7UDRDMTJZA5CNFSM4KWYCJJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMACWHI#issuecomment-587213597, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATF4OZ6FMKOEQBVRBBKOLRDMTJZANCNFSM4KWYCJJA .

csharpfritz avatar Feb 18 '20 00:02 csharpfritz