我有一个控制器类如下:
public partial class GenericViewController : Controller
{
public virtual void StoreUrl(string url)
{
Session["URL"] = url;
}
}
我正在尝试使用 jquery ajax 调用此方法,如下所示:
$.ajax(
{
type: "POST",
cache:false,
url: "http://" + baseUrl + "/GenericView/StoreUrl",
data: { url: applicationurl },
error: Error
});
现在,当我触发 ajax 调用时,出现以下错误
[HttpException]: The controller for path '/GenericView/StoreUrl' was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<BeginProcessRequest>b__2()
at System.Web.Mvc.SecurityUtil.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a()
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[TResult](Func`1 func)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
我已尝试执行以下操作以在注册路由中解决此问题,但我仍然收到相同的错误
routes.IgnoreRoute("Ignore/");
routes.IgnoreRoute("{*GenericView}", new { GenView= @"(.*/)?GenericView(/.*)?" });
routes.RouteExistingFiles = false;
routes.IgnoreRoute("GenericView/{*pathInfo}");
附加说明:此代码托管在名为 LookupData 的应用程序中,该应用程序作为应用程序托管在与 url abc.com 映射的 IIS 网站下,然后 abc.com 托管一个执行身份验证的应用程序,abc.com/LookupData 将命中该应用程序托管上面的代码。单独运行时 Lookupdata 不会引发此错误,但是当通过 abc.com 访问时,应用程序无法解析 GenericViewController。
我不明白我的代码中的错误在哪里。任何人都可以提出解决方案吗?