加载控制器出错

时间:2014-06-06 19:39:45

标签: c# asp.net-mvc

我收到以下错误,我不确定为什么我直接从模板运行代码。有没有人在堆栈跟踪中看到我不知道的东西?它发布在下面。

  

服务器错误' /Cfia.Web.MvcTemplate.Example'应用

     

远程服务器返回错误:(404)Not Found。

     

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.Net.WebException:返回远程服务器   错误:(404)未找到。

     

错误来源:

Line 27:         /// Initializes a new instance of the <see cref="ApplicationBaseController" /> class.
Line 28:         /// </summary>
Line 29:         public ApplicationBaseController()
Line 30:         {
Line 31:             ApplicationTitle = Labels.GetLabel("Application.MvcTemplate.Examples");
  

堆栈追踪:

     

[WebException:远程服务器返回错误:(404)Not Found。]   System.Net.HttpWebRequest.GetResponse()+8521152
  System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,ICredentials   凭证,IWebProxy代理,RequestCachePolicy cachePolicy)+160
  System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri,String role,Type   ofObjectToReturn)+328
  System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)+75
  System.Threading.CompressedStack.runTryCode(Object userData)+260
  System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode   code,CleanupCode backoutCode,Object userData)+0
  System.Threading.CompressedStack.Run(CompressedStack compressedStack,   ContextCallback回调,对象状态)+118
  System.Xml.XmlTextReaderImpl.OpenUrl()+ 7534355
  System.Xml.XmlTextReaderImpl.Read()+ 187 7   System.Xml.XmlLoader.Load(XmlDocument doc,XmlReader reader,Boolean   preserveWhitespace)+176 System.Xml.XmlDocument.Load(XmlReader   读者)+144 System.Xml.XmlDocument.Load(String filename)+205
  Cfia.Globalization.Provider.XmlFileLabelProvider.RetrieveAllLabels(的CultureInfo   文化)+424
  Cfia.Globalization.Provider.LabelService.RetrieveAllRawLabels(的CultureInfo   文化)+490
  Cfia.Globalization.Provider.LabelService.RetrieveAllLabels(的CultureInfo   文化)+50
  Cfia.Globalization.Provider.LabelService.Labels(CultureInfo culture)   +344 Cfia.Globalization.Labels.GetLabels(CultureInfo culture)+157 Cfia.Web.Mvc.Menu.FooterLink..ctor()+221
  Cfia.Web.Mvc.ControllerBase.BaseController..ctor()+ 165   Cfia.Web.MvcTemplate.Example2.Controllers.ApplicationBaseController..ctor()   在c:\ Users \ cir-anglinovd \ Documents \ Visual Studio中   2012 \项目\ ContosoUniversity \ Cfia.Web.MvcTemplate.Example2 \ \控制器ApplicationBaseController.cs:29   Cfia.Web.MvcTemplate.Example2.Controllers.HomeController..ctor()in   c:\ Users \ cir-anglinovd \ Documents \ Visual Studio   2012 \项目\ ContosoUniversity \ Cfia.Web.MvcTemplate.Example2 \控制器\ HomeController.cs:30

     

[TargetInvocationException:目标抛出了异常   调用。] System.RuntimeTypeHandle.CreateInstance(RuntimeType   type,Boolean publicOnly,Boolean noCheck,Boolean&amp; canBeCached,   RuntimeMethodHandleInternal&安培; ctor,布尔&amp; bNeedSecurityCheck)+0
  System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,Boolean   skipCheckThis,Boolean fillCache,StackCrawlMark&amp; stackMark)+159
  System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,   Boolean skipCheckThis,Boolean fillCache,StackCrawlMark&amp; stackMark)   +256 System.Activator.CreateInstance(Type type,Boolean nonPublic)+127 System.Activator.CreateInstance(Type type)+11 System.Web.Mvc.DefaultControllerActivator.Create(RequestContext   requestContext,Type controllerType)+92

     

[InvalidOperationException:尝试创建时出错   控制器类型   &#39; Cfia.Web.MvcTemplate.Example2.Controllers.HomeController&#39 ;.确保   控制器有一个无参数的公共构造函数。]
  System.Web.Mvc.DefaultControllerActivator.Create(的RequestContext   requestContext,Type controllerType)+562491
  System.Web.Mvc.DefaultControllerFactory.CreateController(的RequestContext   requestContext,String controllerName)+89
  Castle.Proxies.Invocations.IControllerFactory_CreateController.InvokeMethodOnTarget()   +155 Castle.DynamicProxy.AbstractInvocation.Proceed()+116 Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext   上下文)+71 Castle.DynamicProxy.AbstractInvocation.Proceed()+604   Castle.Proxies.IControllerFactoryProxy.CreateController(的RequestContext   requestContext,String controllerName)+193
  System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase   httpContext,IController&amp;控制器,IControllerFactory&amp;厂)   +305 System.Web.Mvc。&lt;&gt; c__DisplayClass6.b__2()+78 System.Web.Mvc。&lt;&gt; c__DisplayClassb 1.<ProcessInApplicationTrust>b__a() +19 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func 1 func)+128
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   +12551795 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&amp; completedSynchronously)+288

1 个答案:

答案 0 :(得分:0)

我修复了它,只需在web.config文件中进行一些更改。