我一直在尝试访问404的“ localhost / CompanyRegistration / Index” 到目前为止,已返回错误。.伙计们,我在做什么错了??
这是我的RouteConfig.cs
using System.Web.Mvc;
using System.Web.Routing;
namespace Supply_Manager
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}",
new { controller = "Home", action = "Index" }
);
routes.MapRoute(
"CompanyRegistration",
"{controller}/{action}",
defaults: new { controller = "CompanyRegistration", action = "Index"}
);
}
}
}
这是WebApiConfig.cs
using System.Web.Http;
namespace Supply_Manager
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
}
}
}
这是Global.asax.cs
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Http;
namespace Supply_Manager
{
public class Global : HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
这是CompanyRegistrationController
using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Supply_Manager.Controllers
{
[AllowCrossSiteOrigins]
public class CompanyRegistrationController : Controller
{
[HttpPost]
public ActionResult Index()
{
Console.WriteLine("url working ....")
}
}
}
我所有的Controllers都在Controller文件夹中 ConmpanyRegistration Controller文件名为“ CompanyRegistrationController.cs”,但仍无法正常工作,如何解决此问题