Dear all,
Im new to ASP.Net/c# programming..Im trying to develop ecommerce website and i cant understand some codes. Pls help to understand the codes given below.
thank you
if (!app.EndsWith("/")) app += "/"; //???????????????????
relativeUri = relativeUri.TrimStart('/'); //???????????????????
return HttpUtility.UrlPathEncode( String.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri)); //???????????????????
if (page == "1")
return BuildAbsolute(String.Format("Catalog.aspx?DepartmentID={0}", departmentId)); //???????????????????
Please help to understand dynamic link building class
Started by sajee2004, Jul 04 2010 01:02 AM
3 replies to this topic
#1
Posted 04 July 2010 - 01:02 AM
|
|
|
#2
Posted 05 July 2010 - 11:04 AM
/*
if the app string does not end with a / character append the / character to the end
Example:
if app was
http://www.test.com
app becomes
http://www.test.com/
and if app was
http://www.test.com/
app stays
http://www.test.com/
*/
if (!app.EndsWith("/")) app += "/";
/*
Remove all the / characters from the start of the relativeUri string
Example:
if relativeUri was
/////home.aspx
relativeUri becomes
home.aspx
and if relativeUri was
/home.aspx
relativeUri becomes
home.aspx
*/
relativeUri = relativeUri.TrimStart('/');
/*
This is a two parter:
First
String.Format creates a url
For example:
if app was /myApplication/ and relativeUril was home.aspx
(uri is probably the HttpRequest.Uri object assuming localhost)
The string.format statement would generate
http://localhost:80/myApplication/home.aspx
Second:
HttpUtility Encode the whole string to be save to pass as a query string in the url
the return value will probably be
http%3A%2F%2Flocalhost%3A80%2FmyApplication%2Fhome%2Easpx
*/
return HttpUtility.UrlPathEncode( String.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri));
/*
If the string page variable is "1"
Build the Absolute path for string generated from string format
Absolute path tends to be the full URI path from the root of the website
Assuming the variable departmentId is 42
The output would most likely be:
/Catalog.aspx?DepartmentID=42
*/
if (page == "1")
return BuildAbsolute(String.Format("Catalog.aspx?Departme ntID={0}", departmentId));
// I hope that helps
#3
Posted 15 July 2010 - 12:39 PM
JKohnen said:
/*
if the app string does not end with a / character append the / character to the end
Example:
if app was
http://www.test.com
app becomes
http://www.test.com/
and if app was
http://www.test.com/
app stays
http://www.test.com/
*/
if (!app.EndsWith("/")) app += "/";
/*
Remove all the / characters from the start of the relativeUri string
Example:
if relativeUri was
/////home.aspx
relativeUri becomes
home.aspx
and if relativeUri was
/home.aspx
relativeUri becomes
home.aspx
*/
relativeUri = relativeUri.TrimStart('/');
/*
This is a two parter:
First
String.Format creates a url
For example:
if app was /myApplication/ and relativeUril was home.aspx
(uri is probably the HttpRequest.Uri object assuming localhost)
The string.format statement would generate
http://localhost:80/myApplication/home.aspx
Second:
HttpUtility Encode the whole string to be save to pass as a query string in the url
the return value will probably be
http%3A%2F%2Flocalhost%3A80%2FmyApplication%2Fhome%2Easpx
*/
return HttpUtility.UrlPathEncode( String.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri));
/*
If the string page variable is "1"
Build the Absolute path for string generated from string format
Absolute path tends to be the full URI path from the root of the website
Assuming the variable departmentId is 42
The output would most likely be:
/Catalog.aspx?DepartmentID=42
*/
if (page == "1")
return BuildAbsolute(String.Format("Catalog.aspx?Departme ntID={0}", departmentId));
// I hope that helps
Hi Dear Friend
Thank you so much for this grate explanation.. I really appriciate your effort and very understanding.
Thank you so much again. Im really sorry abt late reply,
Cheers
Sajee
#4
Posted 15 July 2010 - 01:03 PM


Sign In
Create Account

Back to top









