asp.net-mvc-areas

ASP.NET MVC Areas with shared layout

感情迁移 提交于 2019-12-03 04:43:40
问题 I have defined an area (Admin) in my ASP.NET MVC 3 application, created _ViewStart.cshtml in that area and added Layout = "~/Views/Shared/_Layout.cshtml"; to it to have a unified site layout. I also added the following code to _Layout.cshtml : if (HttpContext.Current.User.IsInRole("Admin")) { <li>@Html.ActionLink("Items List", "Index", "Items", new { area = "Admin" }, null)</li> } The Admin area is displayed properly having _Layout.cshtml as its layout. But all the navigation links in the

Durandal and MVC4 Areas for multiple SPAs

百般思念 提交于 2019-12-03 03:35:01
I have a internet application mvc4 with areas, for my organization each area represent a SPA and through "Manage NuGet Package" I installed "Durandal 1.2.0", "Durandal Transitions 1.2.0" and "Durandal Router 1.2.0". I organized the folders and quit the "views" and "viewmodels" from folder "App" of Durandal and put the new views in folder "VIews" of mvc4 area for example: Areas-->NewArea-->Views-->ControllerFolder-->views-->shell.html Then I put the '"viewmodels" in "Script" folder for example: Scripts-->NewArea-->ControllerFolder-->viewmodels-->shell.js Scripts-->NewArea-->ControllerFolder--

ASP.NET MVC `Html.ActionLink` between “Areas”

♀尐吖头ヾ 提交于 2019-12-03 02:59:26
问题 I have added a new Area to my MVC3 project and I am trying to link from the _Layout page to the new Area. I have added an Area called 'Admin' that has a controller 'Meets'. I used the visual studio designer to add the area so it has the correct area registration class etc, and the global.asax file is registering all areas. However, when I use the following 2 action links in a page in the root, I run into a few problems: @Html.ActionLink("Admin", "Index", "Meets", new { area = "Admin" }, null)

Is it possible to use different layouts in MVC4 based off of routes?

ぐ巨炮叔叔 提交于 2019-12-03 01:38:41
I have a separate section (route) of my website that I would like to use a different layout/css etc. So when users at the main section of my website they get the default layout. But when they log in and go to the store, the store section (route) uses a different layout/css. So... www.blahblahblah.com/ www.blahblahblah.com/admin/ www.blahblahblah.com/home/contactus/ ...all use the default _Layout BUT... www.blahblahblah.com/store/ www.blahblahblah.com/store/admin/ ...use _LayoutStore I've seen this done based off of roles here ( http://forums.asp.net/t/1653362.aspx/1 ) and here ( How to use

Can Areas in an ASP.NET MVC 2 application map to a subdomain?

做~自己de王妃 提交于 2019-12-02 22:28:39
Is there a way to map the Areas within an ASP.NET MVC 2 application to subdomains such as movies.example.com/Theater/View/2 instead of example.com/Movies/Theater/View/2 where { area = "Movies", controller = "Theater", action = "View", id = 2 }. Eilon Areas are not directly related to routing, so your question becomes "does routing support subdomains?" The answer to that is unfortunately that there is no built-in support for this. However, the good news is that many people have tried and found success with custom code that builds on top of routing: Is it possible to make an ASP.NET MVC route

ASP.NET MVC Areas with shared layout

浪子不回头ぞ 提交于 2019-12-02 19:02:24
I have defined an area (Admin) in my ASP.NET MVC 3 application, created _ViewStart.cshtml in that area and added Layout = "~/Views/Shared/_Layout.cshtml"; to it to have a unified site layout. I also added the following code to _Layout.cshtml : if (HttpContext.Current.User.IsInRole("Admin")) { <li>@Html.ActionLink("Items List", "Index", "Items", new { area = "Admin" }, null)</li> } The Admin area is displayed properly having _Layout.cshtml as its layout. But all the navigation links in the page now point to Admin subfolder. For example in my layout I have <li>@Html.ActionLink("About Us", "About

Not including area name in URL results in “The view 'Index' or its master was not found” instead of 404

谁都会走 提交于 2019-12-02 17:46:02
问题 When I use this URL: http://www.domain.com/Dashboard/Admin/Index My page works as expected. Dashboard is an MVC Area, Admin is the controller and Index is the view. If I remove the area name, like this: http://www.domain.com/Admin/Index Then I get the following error: That's only kind-of expected; shouldn't it be a 404? Why does MVC still successfully locate the controller and attempt to find the view when I don't specify the area? How do I force it to return 404 when area is not included? I

CompliationLock throws HttpException when registering areas for ASP.NET MVC unit tests

假如想象 提交于 2019-12-02 16:08:07
问题 The moment I added a unit test to my ASP.NET MVC application to test some of the area routing, I got an HttpException coming out of the System.Web.Complication.CompilationLock type initializer with the following stack trace. System.Web.HttpException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception. ----> System.TypeInitializationException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception. ----> System

CompliationLock throws HttpException when registering areas for ASP.NET MVC unit tests

邮差的信 提交于 2019-12-02 13:13:30
The moment I added a unit test to my ASP.NET MVC application to test some of the area routing, I got an HttpException coming out of the System.Web.Complication.CompilationLock type initializer with the following stack trace. System.Web.HttpException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception. ----> System.TypeInitializationException : The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception. ----> System.NullReferenceException : Object reference not set to an instance of an object. at System.Web.Compilation.BuildManager

Not including area name in URL results in “The view 'Index' or its master was not found” instead of 404

こ雲淡風輕ζ 提交于 2019-12-02 12:17:59
When I use this URL: http://www.domain.com/Dashboard/Admin/Index My page works as expected. Dashboard is an MVC Area, Admin is the controller and Index is the view. If I remove the area name, like this: http://www.domain.com/Admin/Index Then I get the following error: That's only kind-of expected; shouldn't it be a 404? Why does MVC still successfully locate the controller and attempt to find the view when I don't specify the area? How do I force it to return 404 when area is not included? I've tried changing namespaces but it doesn't make a difference. By default the built-in controller