It would be nice if someone can help me with this problem because I am new to web development and ASP .NET MVC My goal is to design an MVC application that can help users create their own small website. Each user will change the pages of their small websites and an admin panel and get the template of their sites. I think there are scripts to get such a thing, but we need to create ourselves for our specific needs. In the direction of that goal I created a main MVC 3 application and under it I created a field as a site. We want users to have their own sub-domain URLs like www.site1.mainsite.com where site1 is the name of the user's mini site. For this, I have added 2 routes for one and the other for the main route, such as
route. The URL new {controller = "home", action = "index", id = urpremitar.operation} with MapRoute ("default", // root name "{administrator} / {action} / {id}", // parameters , New [] ("Main Site. UI Controller"}); In Region Registry
context.MapRoute ("Sites_default", "{{ New {controller} = {action} / {id} ", new {controller =" home ", action =" index ", id = UrlParameter.Optional}, new {controller = new SiteConstraint ()}, new [] {" MainSite. U.Areas.Site.Controllers "}); Both have the same URL type, but the field There is an obstacle in the path where I
var url = httpContext.Request.Headers [host "]; var storeName = url.Split ('.') [1]; var match = storeName ! = "MoneySite"; Return Match; So far its work, but I do not think it's a good design. Now apart from this, I have another Sitemap and the other is blog. What should be the best way? < Li> Domain name
The other URLs in the domain are assigned by the main controllers R must be handled Thanks in advance
The answer was not even found :( But I wanted to play with the routes and got something with what I was looking for. Root Debugger , helped me see what was going on in the paths When I tried to add another area "admin", and the route below it Registered with
reference. Maprout ("SiteAdmin_default", "Admin / {Admin} / {action} / {id}", New {controller = "Dashboard", Action = "Index", ID = UrlParameter.Optional}, New {Controller = New Site Content ()}, New [] {"mensite.ui.rsus.saidadmin.contentor"}); Things are getting wrong. The root debugger helped me out, what was happening, the order of the routes for me really matters, so I had to make sure that my areas were registered in the correct order.
Regional Registration. Registrar AllAreas () My routes were not registered in the correct order, Googling gave me this helpful method.
public static class root helper {public static zero registrar & lt; T & gt; (Route compilation route, object state) where T: regional registration {var registration = (area registration) catalyst. Creative form (typef (t)); Var context = new zone registration registration (registration area name, route, state); Var tNamespace = register.GetType (). Namespace; If (tNamespace! = Null) {reference. Namespace. Add (tN namespace + ". *"); } Registration. Registrar (reference); }} This method helped me to register the fields in the required order in Global Escorts
RouteHelper.RegisterArea & lt; SiteAdminAreaRegistration & gt; (RouteTable.Routes, zero); Route Alper Registrar Area & lt; SiteArgrrgration & gt; (Route Pathway, Faucet); I am writing this below, which I have received as an answer so that it is useful to anyone else.
Comments
Post a Comment