asp.net-mvc-areas

ASP.NET Help Pages default home page?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 22:59:33
I want to go to http://myserver and be able to get Help Pages as the default home page, so the first thing a guest to http://myserver should see is the Help Page. I have a default route set up like this: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } Then I have my Help Page Area registration set up like this: public override void RegisterArea(AreaRegistrationContext context)

Link to a root controller from area controller in ASP MVC

混江龙づ霸主 提交于 2019-11-29 11:58:11
问题 How can I link to one of my root controllers from one of my areas? <% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %> This gives me an error: No route in the route table matches the supplied values. I have a controller named Page in a folder named Admin in my root controller collection. I can reach this controller by typing \Admin\Page. This is how I registered the route: routes.MapRoute( "Admin", "Admin/{controller}/{action}/{id}", new { controller = "Admin",

ASP.NET MVC ActionLink outside area

泪湿孤枕 提交于 2019-11-29 10:45:31
问题 A simple task in MVC, sometimes becomes a hard challenge. Well,i have an Area called Admin. I've a page named "Forbidden" inside the Shared's directory in this area. The goal is simple: I need to create an Html.ActionLink that generates a link to return to Home page which is OUTSIDE the Admin area. So i try, <%= Html.ActionLink("Back","Index",new {controller="Home"})%> ,and its generate : http://localhost/Admin/Home/Index Its wrong!I want: http://localhost/Home/Index How can i create a link

MVC Areas - View not found

青春壹個敷衍的年華 提交于 2019-11-29 08:12:52
问题 I have a project that is using MVC areas. The area has the entire project in it while the main "Views/Controllers/Models" folders outside the Areas are empty barring a dispatch controller I have setup that routes default incoming requests to the Home Controller in my area. This controller has one method as follows:- public ActionResult Index(string id) { return RedirectToAction("Index", "Home", new {area = "xyz"}); } I also have a default route setup to use this controller as follows:- routes

The view 'Index' or its master was not found.

戏子无情 提交于 2019-11-29 00:50:07
The view 'Index' or its master was not found. The following locations were searched: ~/Views/ControllerName/Index.aspx ~/Views/ControllerName/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx I got this error when using ASP.Net mvc area. The area controller action are invoked, but it seems to look for the view in the 'base' project views instead of in the area views folder. What you need to do is set a token to your area name: for instance: context.MapRoute( "SomeArea_default", "SomeArea/{controller}/{action}/{id}", new { controller = "SomeController", action = "Index", id =

ASP.NET MVC4 List of all areas

人盡茶涼 提交于 2019-11-29 00:23:41
问题 I have an ASP.NET MVC4 application in which I am creating multiple areas, is there a way I can find out programmatically the number of areas that are present and their names. 回答1: The AreaRegistration.RegisterAllAreas(); registers each area route with the DataTokens["area"] where the value is the name of the area. So you can get the registered area names from the RouteTable var areaNames = RouteTable.Routes.OfType<Route>() .Where(d => d.DataTokens != null && d.DataTokens.ContainsKey("area"))

How to Configure Areas in ASP.NET MVC3

旧巷老猫 提交于 2019-11-28 17:13:00
Is anyone knows how to Configure Areas in ASP.NET MVC3. I read an article about Areas in here . But that article is not based on MVC3. In MVC3 there is no function named MapRootArea in RouteCollection routes which is found in Global.asax routes.MapRootArea("{controller}/{action}/{id}", "AreasDemo", new { controller = "Home", action = "Index", id = "" }); When i create a New Area using MVC3, i got a class of that area which inherited from AreaRegistration and look like following: (here Blogs is the area name) public class BlogsAreaRegistration : AreaRegistration { public override string

Controllers split by areas [duplicate]

我只是一个虾纸丫 提交于 2019-11-28 07:48:35
Possible Duplicate: How do I register a controller that has been created in an AREA I have the question - is it possible to do the next? I have three Areas: _Default SiteOne SiteTwo Inside each area i have a ApiController with the same name, but in different namespaces of course: MvcAppliaction.Areas._Default.Controllers.ValuesController MvcAppliaction.Areas.SiteOne.Controllers.ValuesController MvcAppliaction.Areas.SiteTwo.Controllers.ValuesController I also have a value of current (which i would like to use) Area in configuration. I would like to map user to controller in the proper Area

Relative Content Path in MVC3 Areas

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 06:57:38
I found this question Can't use relative paths with areas in ASP.NET MVC 2 which is the same issue I am having. Is this still the case in MVC3? Is there a way to keep content files in an area relative to the area? So that a layout file in an area can have something like Without having to either make a fully qualified link, requiring the areas directory and the area name or the solution of the above question which requires a check for each area on each request. update/edit I've decided to use both the solution in the above question and the one below (html helper) - depending on the project

How can we set authorization for a whole area in ASP.NET MVC?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 04:49:59
I've an Admin area and I want only Admins to enter the area. I considered adding the Authorized attribute to every controller in the Admin area. Isn't there an elegant solution or is this feature not there in the framework itself? EDIT: I'm sorry, I should to have mentioned this before. I'm using a custom AuthorizedAttribute derived from AuthorizeAttribute. Web.config-based security should almost never be used in an MVC application. The reason for this is that multiple URLs can potentially hit a controller, and putting these checks in Web.config invariably misses something. Remember -