Paging and routing in ASP.Net MVC -


I am following the following and when I was helpful I raised some issues which I do not understand.

Martian says:

Internally, using the pathTab.Rout.GetVidualPath () to use pager, URL's so much that routing the page URL Can be configured via '/ paging / viewbc category? Instead of 'name = shoes and page = 1', the good looking URL can be prepared for '/ categories / shoes / page / 1'.

This is what he is talking about:

  Private string GeneratePageLink (string link text, int page number) {var pageLinkValueDictionary = New Root Voltage (this.linkWithoutPageValuesDictionary); PageLinkValueDictionary.Add ("Page", page number); // var virtual pathadata = this.viewContext.RouteData.Route.GetVirtualPath (this.viewContext, pageLinkValueDictionary); Var Virtual Pathadata = RootTable.Rout GetVirtualPath (this.viewContext.RequestContext, pageLinkValueDictionary); If (virtualPathData! = Null) {string linkFormat = "& lt; a href = \" {0} \ "& gt; {1}  

How does this work? When I use it virtualPathData.VirtualPath, a URL of the first path is returned to my routing table, which is not the end with 'Page' Ultimate, but a URL that represents the current reference.

In addition to this, 'routing' / paging / viewsBB category 'name = shoes and page = 1' to '/ categories / shoes / page / 1'?

I think you have a paging controller and this controller has ViewByCategory verb.

ViewByCategory looks like this:

  public action view ViewByCategory (string will appear as routing code  
  public static zero register rows (root Collection route) {routes.IgnoreRoute () "{} resource .axd / {* pathInfo}"); Routes Marker ("Rootbike category", "Categories / {categoryName} / page / {page}", new {controller = "paging", action = "View category"}); Routes MapRoute ("Route range first page", "Categories / {categoryName}", new {controller = "paging", action = "visualbib category", page = 1}); New {controller = "home", action = "index", id = ""} with routes ("default", // root name "{controller} / {action} / {id}", // URL parameter / Parameter defaults); } Secure Zero Application_start () {RegisterRout (RouteTable.Rout); }  

GeneratePageLink will return the link in '/ Categories / Shoes / Page / 1' format, because this is the first matching path pattern in the routing table.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -