So I was reading an article on MikesDotNetting about routing, and it said not all web crawlers will crawl a website with a url like csharp/Page?id=1 it obvisouloy does not mean anything so I am thinking which URL should I got with:
1. csharp/Page?id=1
2. csharp/Page/1
or
3. csharp/Page/and-page-name
For the last option the problem would be I do have characters which will need correct formatting, I got stuff like #, >, =, so I think the first or second option would be good. if I wanted to change my page to the 2 option how would I do it? The code for
the page.cshtml is this:
var PageName = Context.GetRouteValue("PageName");
if (PageName == null){Response.Redirect("~/Default.cshml");}
var id=Request["id"];
var SQLSELECT = "SELECT * FROM Pages WHERE ID=@0";
var db = Database.Open("Site");
var data = db.QuerySingle(SQLSELECT, id);
if (data == null){
Response.Redirect("~/Error.cshtml");
}
var pName = data.pName;
var pTitle = data.pTitle;
var pKeywords = data.pKeywords;
var pDescription = data.pDescription;
var pBody = data.pBody;
var pCategory = data.pCategory;
var pSiteMap = data.pSiteMap;
var pLastEdited = data.pLastEdited;
var pLayout = data.pLayout;
Page.Title = pName;
Page.mKeywords = pKeywords;
Page.mDescription = pDescription;
Layout="~/Layouts/" + pLayout;
}
<h4 class="Title">@pTitle</h4>
@Html.Raw(pBody)
I don't know nothing about the Routing For Web Pages package, but if your problem is to convert your page from QueryStrings to UrlData you can accomplish this simply replacing
The technique you requires is call URL REWRITING in earlier versions of ASP.NET, and ROUTING in 3.5 onwards.
You will have to make sure your IIS (webserver) supports this.
Thanks I installed it and I have managed to do it, but I have one problem, the url like csharp/Page/1 that csharp is just ASP.NET routing if I change it to html/Page/1 then it will require full query string like Page?id=1 do I need to make pattern for each
route or can I set some kind of wildcard default value.?
1) My guess is that "razorc" is the name of the folder you keep your site in - the reason why you see razorc in url is becausse the hosting company you use. This is something they did not fix for years, and when you try to host multiple sites, you will see
problems like that. Don't want to go into details here but you can find more info about this on your host website
2) between
1. csharp/Page?id=1
2. csharp/Page/1
#2 is better for the end user /simpler
both will work and modern spider will not have any problems to index your pages
HOWEVER #3 csharp/page-name-here - would be the best from SEO point of view
CriticalErro...
Member
450 Points
409 Posts
URL Formatting.. which is better Page?id=1 or Page/1
Aug 18, 2012 07:04 PM|LINK
So I was reading an article on MikesDotNetting about routing, and it said not all web crawlers will crawl a website with a url like csharp/Page?id=1 it obvisouloy does not mean anything so I am thinking which URL should I got with:
1. csharp/Page?id=1
2. csharp/Page/1
or
3. csharp/Page/and-page-name
For the last option the problem would be I do have characters which will need correct formatting, I got stuff like #, >, =, so I think the first or second option would be good. if I wanted to change my page to the 2 option how would I do it? The code for the page.cshtml is this:
var PageName = Context.GetRouteValue("PageName"); if (PageName == null){Response.Redirect("~/Default.cshml");} var id=Request["id"]; var SQLSELECT = "SELECT * FROM Pages WHERE ID=@0"; var db = Database.Open("Site"); var data = db.QuerySingle(SQLSELECT, id); if (data == null){ Response.Redirect("~/Error.cshtml"); } var pName = data.pName; var pTitle = data.pTitle; var pKeywords = data.pKeywords; var pDescription = data.pDescription; var pBody = data.pBody; var pCategory = data.pCategory; var pSiteMap = data.pSiteMap; var pLastEdited = data.pLastEdited; var pLayout = data.pLayout; Page.Title = pName; Page.mKeywords = pKeywords; Page.mDescription = pDescription; Layout="~/Layouts/" + pLayout; } <h4 class="Title">@pTitle</h4> @Html.Raw(pBody)Help will be apprectiated..
My Site | My Blog
shibuv
Member
189 Points
34 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 18, 2012 07:28 PM|LINK
The technique you requires is call URL REWRITING in earlier versions of ASP.NET, and ROUTING in 3.5 onwards.
You will have to make sure your IIS (webserver) supports this.
GmGregori
Contributor
5564 Points
749 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 18, 2012 09:00 PM|LINK
I don't know nothing about the Routing For Web Pages package, but if your problem is to convert your page from QueryStrings to UrlData you can accomplish this simply replacing
with
I hope this helps you.
CriticalErro...
Member
450 Points
409 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 18, 2012 09:01 PM|LINK
Thanks I installed it and I have managed to do it, but I have one problem, the url like csharp/Page/1 that csharp is just ASP.NET routing if I change it to html/Page/1 then it will require full query string like Page?id=1 do I need to make pattern for each route or can I set some kind of wildcard default value.?
My Site | My Blog
Ahmed Abdulr...
Participant
906 Points
232 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 18, 2012 09:15 PM|LINK
i think number 2 is the best route map ! because its meaningfull and has the ability to post extra http variable i.e:
csharp/Page/1?name=intro
CriticalErro...
Member
450 Points
409 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 19, 2012 12:21 AM|LINK
I have done it but I get one problem if you go here >
http://razorc.thecodingguys.net/
the links work like /wiki/5 but if a user types wiki?id=5 it goes to razorc/wiki/5 why does it put that razorc there?
My Site | My Blog
TOMCIO
Contributor
3648 Points
833 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 19, 2012 03:38 AM|LINK
1) My guess is that "razorc" is the name of the folder you keep your site in - the reason why you see razorc in url is becausse the hosting company you use. This is something they did not fix for years, and when you try to host multiple sites, you will see problems like that. Don't want to go into details here but you can find more info about this on your host website
2) between
1. csharp/Page?id=1
2. csharp/Page/1
#2 is better for the end user /simpler
both will work and modern spider will not have any problems to index your pages
HOWEVER #3 csharp/page-name-here - would be the best from SEO point of view
Web: Chicago Website Design
r@zorC - Open Source ASP.net CMS for WebMatrix
JTS-V
Member
29 Points
19 Posts
Re: URL Formatting.. which is better Page?id=1 or Page/1
Aug 19, 2012 05:44 AM|LINK
Please "Mark As Answer" if the post helped you.