PDA

View Full Version : مشکل در کار نکردن متد ReWritePath



HossainE
شنبه 23 مرداد 1395, 00:00 صبح
سلام.
من یک مشکلی دارم به این صورت که یک کلاس در app_code درست کردم و با استفاده از این کلاس و module میخواستم که ReWriting صفحات برام انجام بشه که همون اول کار به مشکل بر خوردم.
مشکل این هست که بعد از اجرا صفحه باز میشه بدون هیچ ایرادی ولی URL ریرایت نمیشه
در web.config هم کارهای لازم رو انجام دادم و مودول کار میکنه ولی ریرایت کار نمیکنه این چند خط کدی هست که نوشتم :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


/// <summary>
/// Summary description for GetProductInfo
/// </summary>
public class GetProductInfo:IHttpModule
{
public GetProductInfo()
{
//
// TODO: Add constructor logic here
//
}


public void Dispose()
{
throw new NotImplementedException();
}


public void Init(HttpApplication context)
{
context.BeginRequest += Context_BeginRequest;

}


private void Context_BeginRequest(object sender, EventArgs e)
{
HttpApplication App = sender as HttpApplication;


if (App.Request.Path.Contains("ProductPage.aspx"))
{

string[] Parts = App.Request.Path.Split('/');
// App.Response.Write(Parts.Length);
if (Parts.Length < 3)
{
App.Context.RewritePath("ProductPage.aspx/?Color=");
App.Response.Write("tetst");
}




else
App.Context.RewritePath("ProductPage.aspx?color=" + Parts[Parts.Length - 1]);


}
}
}