我需要帮助。我无法从主项目访问我的便携区域。我构建了所有内容,在尝试访问这个可移植区域(localhost:123/IW/Home)时出现404错误,但所有常规区域都工作正常(例如:localhost:123/Portal/Home)
-我下载了MVCContrib
-我在主项目中添加了对MVCContrib.dll的引用(称为WAB)
-我用和WAB相同的解决方案创建了一个新的类库项目。
-这个新类库叫做iPortableArea,我添加了必要的程序集引用(MVCContrib、System.mvc,…)
-我创建了一个IWRegistration:
namespace IWPortableArea
{
public class IWRegistration : PortableAreaRegistration
{
public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context, IApplicationBus bus)
{
context.MapRoute(
"iw",
"iw/{controller}.aspx/{action}",
new { controller = "login", action = "index" });
RegisterAllAreas(GetType());
}
public override string AreaName
{
get { return "iw"; }
}
}
}
namespace IWPortableArea.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return Content("yo you are in IW Portable Area, congrats");
}
}
}
-我在主项目中添加了对可移植区域的引用:iwportablerea.dll
-最后,我将主应用程序的Global.asax.cs修改为:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Portal", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}