Blog Stats
  • Posts - 35
  • Articles - 0
  • Comments - 3
  • Trackbacks - 2

 

Url Rewriting

<div class="post-body">
<p>
</p>
<div style="CLEAR: both">
</div>
<span style="color:#ff0000;"><strong>First Sample </strong>


</span>


string StrFilePath = Request.FilePath;

int intStart = StrFilePath.LastIndexOf("/") + 1 ;

int intEnd = StrFilePath.LastIndexOf(".aspx");

int intLength = intEnd - intStart; //CHECK THE URL STRING FOR USER SUB DIRECTORY

if(intEnd&gt;0 &amp;& intStart&gt;0)

{

StrFilePath = StrFilePath.Substring(intStart,intLength);//TRANSFER THE VISITOR TO
THE COMMON PAGE10:

string strselect ="select fieldname from tablemaster where fieldname='"+StrFilePath.Replace("'","''")+"'";

SqlDataReader Oreader=null;

Oreader=res.getReader(strselect);

if(Oreader.Read())

{

 

if(StrFilePath.IndexOf("StrFilePath")&lt;0) { Context.RewritePath("Listing.aspx?Id="+Oreader["ID"].ToString()+"");
} } Oreader.Close();

 

 

<span style="color:#ff0000;"></span><strong><span style="color:#ff0000;">Second Sample</span>
</strong>

 


string OriginalPath = HttpContext.Current.Request.Path;

Regex r = new Regex(@"(\d+)");

Match m = r.Match(OriginalPath);

try

{

int id = Convert.ToInt32(m.ToString());

HttpContext.Current.RewritePath("MyPage.aspx?id="+id);

}

catch {}

 

 

<span style="color:#ff0000;"><strong>Handling PostBack</strong>

</span>


RegisterStartupScript( "PostBackFix",

"&lt;script&gt; document.forms[0].action=''; &lt;/script&gt;

 

" );</div>


Feedback

# re: Url Rewriting

Gravatar is this working for subtext blog? 12/25/2008 5:56 PM | victorantos

Post a comment





 

 

 

Copyright © Sharvan Dhaka