November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
What is your routing table content?
For instane, if I want to add additional diagnostics controller to my EPiServer site I add following in Global.ascx.cs:
protected override void RegisterRoutes(RouteCollection routes)
{
base.RegisterRoutes(routes);
routes.MapRoute("AdditionalDiagnosticRoutes",
"diag/{controller}/{action}/{param}",
new { action = "Index", param = RouteParameter.Optional });
}
When I do this override and single step during debug it doesn't hit this class. My global.asax.cs class looks like this.
protected override void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
base.RegisterRoutes(routes);
routes.MapRoute(
"JsonGetX", // Route name
"Surface/JsonGetX", // URL with parameters
new { controller = "Surface", action = "JsonGetX" }
);
}
I have a controller that looks like this
public class SurfaceController : Controller
{
[HttpGet]
public ActionResult JsonGetX()
{
return Json(new { Success = true }, JsonRequestBehavior.AllowGet);
}
}
EDIT: I changed the routing to this so that we can exclude me doing wrong in the routing syntax
protected override void RegisterRoutes(RouteCollection routes)
{
base.RegisterRoutes(routes);
routes.MapRoute(
"JsonGetX", // Route name
"Surface/{controller}/{action}/{param}", // URL with parameters
new { action = "Index", param = RouteParameter.Optional }
);
}
If method is not hit then you can verify Global.asax file that you are really inheriting from your class:
<%@ Application Language="C#" Inherits="YourProject.Web.Global" %>
OK, where do I do write this?, If i put in my master page/ layout file (razor) I get an exception.
If you have Global.asax.cs file, there should be also Global.asax file, edit that. Note that if you double-click Global.asax file in VS - it still will open Global.asax.cs file :) Who needs to edit .asax file anyway, right!? :)
Thanks :) Don't know if this brings us closer to the problem but I changed to the path of my Global.asax.cs. This is the error message. I have no clue what this means, if it is me doing wrong in the <%@ Application Language="C#" Inherits="MyProject.Global" %> or if I need to change something else as well.
Unable to load one or more of the requested types. The following information may be a subset of the Type/LoaderException information present - inspect with debugger for complete view.
Check assemblies [EPiServer.Search.IndexingService, Version=7.0.1764.1, Culture=neutral, PublicKeyToken=8fe83dea738b45b7] and/or types [EPiServer.Search.IndexingService.IPRange,
EPiServer.Search.IndexingService.FieldProperties,
EPiServer.Search.IndexingService.FieldSerializers.IndexFieldStoreSerializerBase,
EPiServer.Search.IndexingService.FieldSerializers.TaggedFieldStoreSerializer,
EPiServer.Search.IndexingService.FieldSerializers.AclFieldStoreSerializer,
EPiServer.Search.IndexingService.FieldSerializers.PipeSeparatedFieldStoreSerializer,
EPiServer.Search.IndexingService.FieldSerializers.AuthorsFieldStoreSerializer,
EPiServer.Search.IndexingService.FieldSerializers.CategoriesFieldStoreSerializer,
EPiServer.Search.IndexingService.Configuration.ClientCollection,
EPiServer.Search.IndexingService.Configuration.ClientElement,
EPiServer.Search.IndexingService.Configuration.IndexingServiceSection,
EPiServer.Search.IndexingService.Configuration.NamedIndexCollection,
EPiServer.Search.IndexingService.Configuration.NamedIndexElement,
EPiServer.Search.IndexingService.Configuration.NamedIndexesElement,
EPiServer.Search.IndexingService.FieldSerializers.VirtualPathFieldStoreSerializer,
EPiServer.Search.IndexingService.IndexingServiceSettings,
EPiServer.Search.IndexingService.InternalServerErrorEventArgs,
EPiServer.Search.IndexingService.OptimizedEventArgs,
EPiServer.Search.IndexingService.RemoveEventArgs,
EPiServer.Search.IndexingService.AddUpdateEventArgs]. Information from LoaderExceptions property [Could not load file or assembly 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=8fe83dea738b45b7' or one of its dependencies. The system cannot find the file specified.].
EDIT: It's the same message as if I would do @inherits MyProject.Global in the razor page.
EDIT: Solved it. Thanks for your help. The last error here I don't know why it happened. Two references had stopped working. The only reason I can think of why they stopped working is because I recently updated to 7.1. Don't know if it is that or something else. Thanks again! EPIServer just got more fun :)
I want to call an action that has nothing to do with a page in EPIServer. When I set up a controller and call an action I only get
HTTP Error 404.0 - Not Found
What do I need to do to be able to call a normal MVC controller?
Thanks!