user10249871
user10249871

Reputation:

mvc layout page misbehaving with ui in mobile devices

I am creating a web app in mvc using Javascript and Jquery.

when I comment the line for layout which is below,

//Layout = "~/Views/Shared/myLayout.cshtml";

this

my ui looks fine in all the mobile devices, but when I un-comment this line like the following,

Layout = "~/Views/Shared/myLayout.cshtml";

this

my font-size decreases and it makes very difficult to understand,

my myLayout.cshtml is empty

what is the problem here and how can I solve this?

Upvotes: 1

Views: 26

Answers (1)

prinkpan
prinkpan

Reputation: 2247

Kindly edit your myLayout.cshtml to

<!DOCTYPE html>
<html lang="en">
<head>
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    @RenderBody()
</body>
</html>

Then in your view, remove all the <html>, <head> and <body> tags.

The trick here is <meta> tag. You can learn more about it here.

Upvotes: 1

Related Questions