I need to simplify this code to avoid hardcoding. I mean the variable baseUrl
<div class="pagination">
@{
int pageIndex = ViewBag.PageIndex;
int pageSize = ViewBag.PageSize;
int rowsCount = ViewBag.TotalRecords;
string locale = ViewBag.Locale;
string baseUrl = pageIndex == 1 ?
Request.RawUrl + "/page" :
string.Format("/{0}/tags/{1}/page", locale, Request.RequestContext.RouteData.Values["tag"]);
}
@Html.Pager(baseUrl, pageIndex, pageSize, rowsCount)
</div>
Probably you have route whitch handles such URLs. So use
@Url.RouteUrl("routename", route_data)where in route date you will put all necessary values: