I have a solution that works in Episerver 10 but it doesnt work in Episerver 7. We have a customer who wants his solution in Episerver 7.
I have a controller with the name DigitalanslagstavlaPageController. This controller has two action. Index och GetDocument.
Index list information in the html view. GetDocument read a document from a webservice.
Index list information in the html view. GetDocument read a document from a webservice.
I get a list from action Index. It works.
I create a link to a document with
<a href="@Url.Action("GetDocument", new { Id = @doc.Id })" title="Read document" target="_self">@doc.GetHyperLinkText()</a>
It creates a link that looks like this http://localhost:37008/DBB7Page/GetDocument/?Id=517
I have tried to add the controller name to Url.Action. But it doesent work. Same error
When i press the link i want to get the document from the webservice and go to a html view that show this document
This work in Episerver 10, but not in Episerver 7.
I get
Server Error ‘/’ Application
Content with id 517 was not found
*
*
Server Error ‘/’ Application
Content with id 517 was not found
*
*
You have the stack trace last
I know that the document with id exist in the database. I know that my back-end code works to.
I think it is a routing problem. Can anyone give me tips on how to solve the problem
This is my controller
public class DigitalanslagstavlaPageController : PageController<DigitalanslagstavlaPage>
{
{
[HttpGet]
public ActionResult Index(DigitalanslagstavlaPage currentPage)
{
/* CODE THAT DO STUFF */
return View(currentPage);
}
public ActionResult Index(DigitalanslagstavlaPage currentPage)
{
/* CODE THAT DO STUFF */
return View(currentPage);
}
[HttpGet]
public ActionResult GetDocument(DigitalanslagstavlaPage currentPage, int? Id)
{
/* CODE THAT DO STUFF */
return View(currentPage);
}
}
public ActionResult GetDocument(DigitalanslagstavlaPage currentPage, int? Id)
{
/* CODE THAT DO STUFF */
return View(currentPage);
}
}
My MVC routing is
public class EPiServerApplication : EPiServer.Global
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
}
protected override void RegisterRoutes(RouteCollection routes)
{
base.RegisterRoutes(routes);
{
base.RegisterRoutes(routes);
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
defaults: new { controller = "DigitalanslagstavlaPage", action = "Index", id = UrlParameter.Optional });
}
}
"Default",
"{controller}/{action}/{id}",
defaults: new { controller = "DigitalanslagstavlaPage", action = "Index", id = UrlParameter.Optional });
}
}
STACK TRACE:
[ContentNotFoundException: Content with id 517 was not found]
EPiServer.DataAccess.ContentDB.ThrowNotFoundException(ContentReference contentLink) +135
EPiServer.DataAccess.ContentLoadDB.LoadContentInternal(ContentReference contentLink, Int32 languageBranchId, DbDataReader reader) +306
EPiServer.DataAccess.<>c__DisplayClass1.<Load>b__0() +328
EPiServer.Data.Providers.<>c__DisplayClass1`1.<Execute>b__0() +87
EPiServer.Data.Providers.SqlDeadlockRetryPolicy.Execute(Boolean isInTransaction, Func`1 method) +142
EPiServer.Data.Providers.SqlDatabaseHandler.Execute(Func`1 action) +303
EPiServer.DataAccess.ContentLoadDB.Load(ContentReference contentLink, Int32 languageBranchID) +286
EPiServer.DataAbstraction.ContentStore.Load(ContentReference contentLink, Int32 languageBranchID) +67
EPiServer.DefaultContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) +562
EPiServer.Core.<>c__DisplayClassf.<LoadContentFromCacheOrRepository>b__d() +190
EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject) +794
EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +1088
EPiServer.Core.ContentProvider.Load(ContentReference contentLink, ILanguageSelector selector) +75
EPiServer.DataFactory.Get(ContentReference contentLink, ILanguageSelector languageSelector) +395
EPiServer.DataFactory.Get(ContentReference contentLink) +168
EPiServer.Web.Mvc.ExistingActionRouteConstraint.Match(HttpContextBase httpContext, Route route, String parameterName, RouteValueDictionary values, RouteDirection routeDirection) +265
EPiServer.Web.Routing.ContentRoute.MatchConstraints(SegmentContext segmentContext, HttpContextBase context) +650
EPiServer.Web.Routing.ContentRoute.GetRouteData(HttpContextBase httpContext) +670
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +235
EPiServer.Web.Routing.RouteCollectionExtensions.HandleRouteData(RouteCollection routes, HttpContextBase context) +68
EPiServer.Global.DefaultDocumentHandling(Object sender, EventArgs e) +215
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
EPiServer.DataAccess.ContentDB.ThrowNotFoundException(ContentReference contentLink) +135
EPiServer.DataAccess.ContentLoadDB.LoadContentInternal(ContentReference contentLink, Int32 languageBranchId, DbDataReader reader) +306
EPiServer.DataAccess.<>c__DisplayClass1.<Load>b__0() +328
EPiServer.Data.Providers.<>c__DisplayClass1`1.<Execute>b__0() +87
EPiServer.Data.Providers.SqlDeadlockRetryPolicy.Execute(Boolean isInTransaction, Func`1 method) +142
EPiServer.Data.Providers.SqlDatabaseHandler.Execute(Func`1 action) +303
EPiServer.DataAccess.ContentLoadDB.Load(ContentReference contentLink, Int32 languageBranchID) +286
EPiServer.DataAbstraction.ContentStore.Load(ContentReference contentLink, Int32 languageBranchID) +67
EPiServer.DefaultContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) +562
EPiServer.Core.<>c__DisplayClassf.<LoadContentFromCacheOrRepository>b__d() +190
EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject) +794
EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +1088
EPiServer.Core.ContentProvider.Load(ContentReference contentLink, ILanguageSelector selector) +75
EPiServer.DataFactory.Get(ContentReference contentLink, ILanguageSelector languageSelector) +395
EPiServer.DataFactory.Get(ContentReference contentLink) +168
EPiServer.Web.Mvc.ExistingActionRouteConstraint.Match(HttpContextBase httpContext, Route route, String parameterName, RouteValueDictionary values, RouteDirection routeDirection) +265
EPiServer.Web.Routing.ContentRoute.MatchConstraints(SegmentContext segmentContext, HttpContextBase context) +650
EPiServer.Web.Routing.ContentRoute.GetRouteData(HttpContextBase httpContext) +670
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +235
EPiServer.Web.Routing.RouteCollectionExtensions.HandleRouteData(RouteCollection routes, HttpContextBase context) +68
EPiServer.Global.DefaultDocumentHandling(Object sender, EventArgs e) +215
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69