0
votes

I'm getting the following error and I'm not sure why as I am running code straight off of a template. Does anyone see something in the stack trace that I don't? It is posted below.

Server Error in '/Cfia.Web.MvcTemplate.Example' Application.

The remote server returned an error: (404) Not Found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (404) Not Found.

Source of Error:

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");

Stack Trace:

[WebException: The remote server returned an error: (404) Not Found.] System.Net.HttpWebRequest.GetResponse() +8521152
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, 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 callback, Object state) +118
System.Xml.XmlTextReaderImpl.OpenUrl() +7534355
System.Xml.XmlTextReaderImpl.Read() +187
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +176 System.Xml.XmlDocument.Load(XmlReader reader) +144 System.Xml.XmlDocument.Load(String filename) +205
Cfia.Globalization.Provider.XmlFileLabelProvider.RetrieveAllLabels(CultureInfo culture) +424
Cfia.Globalization.Provider.LabelService.RetrieveAllRawLabels(CultureInfo culture) +490
Cfia.Globalization.Provider.LabelService.RetrieveAllLabels(CultureInfo culture) +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() in c:\Users\cir-anglinovd\Documents\Visual Studio 2012\Projects\ContosoUniversity\Cfia.Web.MvcTemplate.Example2\Controllers\ApplicationBaseController.cs:29 Cfia.Web.MvcTemplate.Example2.Controllers.HomeController..ctor() in c:\Users\cir-anglinovd\Documents\Visual Studio 2012\Projects\ContosoUniversity\Cfia.Web.MvcTemplate.Example2\Controllers\HomeController.cs:30

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& 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: An error occurred when trying to create a controller of type 'Cfia.Web.MvcTemplate.Example2.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
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 context) +71 Castle.DynamicProxy.AbstractInvocation.Proceed() +604 Castle.Proxies.IControllerFactoryProxy.CreateController(RequestContext requestContext, String controllerName) +193
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +305 System.Web.Mvc.<>c__DisplayClass6.b__2() +78 System.Web.Mvc.<>c__DisplayClassb1.<ProcessInApplicationTrust>b__a() +19 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func1 func) +128
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12551795 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

1
Odds are you are not hitting the controller method. The error code is from IIS meaning that the URL is probably wrong.Keith Payne
What do you mean that the URL is probably wrong? You think it doesn't match a valid route defined in the route table?user1410668
You need to show the code where you get the error as well.JB06
I think you need to provide the ApplicationBaseController constructor code and after that what is Labels?VahidNaderi

1 Answers

0
votes

I fixed it, just had to make some changes in the web.config file.