We're working on an MVC application at the moment and we're running into some issues with our URL's.
We have two simple action methods in a controller:
publicPartialViewResultIndex(ListingPagePress currentPage){var model =newListingPagePressViewModel(currentPage);var pressReleaseChildren =GetData(currentPage,0);
model.PressReleasePages= pressReleaseChildren;
model.TotalPages=3;returnPartialView(model);}publicPartialViewResultPressReleaseList(ListingPagePress currentPage,int pageNo){IEnumerable<>>PressReleasePageViewModel> data =GetData(currentPage, pageNo);returnPartialView(data);}
The PressReleaseList is rendered using an action (on the index view), i.e.:
@Html.Action("PressReleaseList", new { pageNo = 0 })
and then we have some simple pagination (again on the index view):
@for(var i =0; i <>>Model.TotalPages; i++){@Ajax.ActionLink(i.ToString(),"Index",new{ pageNo = i },newAjaxOptions{UpdateTargetId="pressReleaseTable",OnBegin="OnAjaxRequestBegin",OnFailure="OnAjaxRequestFailure",OnSuccess="OnAjaxRequestSuccess",OnComplete="OnAjaxRequestComplete"})}
The unobtrustive ajax is working just fine. The problem is, if the client has javascript disabled they end up navigating to the partialview via a horrid url such as:
How do we acheive this? Is mapping a route the only possibility? That would be quite hard fro us because we're working with a CMS, so we never know what the exact url prefix would be because the User could change the url of "press-releases".
We're working on an MVC application at the moment and we're running into some issues with our URL's.
We have two simple action methods in a controller:
The PressReleaseList is rendered using an action (on the index view), i.e.:
@Html.Action("PressReleaseList", new { pageNo = 0 })
and then we have some simple pagination (again on the index view):
The unobtrustive ajax is working just fine. The problem is, if the client has javascript disabled they end up navigating to the partialview via a horrid url such as:
http://example.com/press-releases/PressReleaseList/?pageNo=1
Whereas we want to retain the true URL structure which would be: http://example.com/press-releases/?pageNo=1
How do we acheive this? Is mapping a route the only possibility? That would be quite hard fro us because we're working with a CMS, so we never know what the exact url prefix would be because the User could change the url of "press-releases".
Any advice would be greatly appreciated