0

I'm doing some development where I need to implemented a login form in MVC. I have already created an MVC project in VS2013 which works OK. When creating it, VS already include the forms and configuration to use the LogIn as well as the register views.

the thing here is that that view use the layout.cshtml file as a master page. So, if I put the [Authorize] attribute to a method inside a controller what is happening when running the web site, is that it shows the LogIn page which is OK. But using the layout.cshtml as the master page.

Is there a way to displayed the LogIn.cshtml page in the entiry window without using the layout.cshtml?

In the web.config I have:

<authentication mode="Forms"> <forms loginUrl="Account/Login" timeout="2880" /> </authentication> 

But it doesn't work

1
  • you have to create a new login page and set it as the view page in the controller action method. doing so you can have a separate layout page for the login view alone. HTH Commented Mar 7, 2015 at 6:29

1 Answer 1

4

The layout applied to the Login.cshtml is being picked up, by convention, from _ViewStart.cshtml.

@{ Layout = "~/Views/Shared/_Layout.cshtml"; } 

If you don't want to use this then add a

@{ Layout = null; } 

or

@{ Layout = "SomeOtherMaster.cshtml"; } 

to the Login.cshtml page.

However by changing the Layout you're going to change out all the script and css references so you'll need to add in you own. You should check in /Views/Shared/_Layout.cshtml to see what you'll be giving up.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help. After trying that code, it works as commented. Now, I'm facing some details to have the following scenario. I want that the first page to appears be the login page (as a splash screen) and the the user log in, the system redirects him/her to the view that will act as the master page. I'm working on that but not having success so far

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.