0

We are building a ASP.NET Core 3.1 Razor web application using .NET Core 3.1 as framework , C# as programming language and Razor pages. The web application has also to be comptaible with mobile devices.

We are new to Razor pages.

We started with creating a basic Razor pages ASP.NET Core web application. We created a login page as the start page.

For making the login page work also in mobile devices, we made changes as per this tutorial : Rendering ASP.NET Web Pages (Razor) Sites for Mobile Devices

We created a version of Pages\Login.cshml with some UI changes and renamed it as Pages\Login.Mobile.cshtml. We also

But at run time, Pages\Login.Mobile.cshtml is not called when a mobile device requests Pages\Login.cshtml.

Question: Why .Mobile.cshtml is not rendered in ASP.NET Core C# Razor Pages Web application?

gurkan
  • 884
  • 4
  • 16
  • 25
devman
  • 496
  • 5
  • 24

1 Answers1

1

That documentation describes a feature of an old version of ASP.NET, namely ASP.NET Web Pages (versions 2.0 to 3.5). This feature was deprecated in ASP.NET 4.

You're using ASP.NET Core 3.1? Core came out after ASP.NET 4, so you can't use that feature anymore.

Rudey
  • 4,717
  • 4
  • 42
  • 84
  • Thanks, How to implement mobile rendering feature in .NET Core Razor pages? Is there any link to tutorial or an example? – devman Aug 14 '20 at 12:12
  • 3
    Serving a different page for mobile browsers is not really a best practice. The best approach is creating responsive web pages that work on both mobile and desktop browsers. People use Bootstrap or similar frameworks to do this, or just write the CSS yourself. – Rudey Aug 14 '20 at 12:21
  • Best solution I've found: https://stackoverflow.com/a/71053664/7204020 Works like a charm in asp.net core. – Sylwia M Mar 17 '22 at 13:56