ASP.Net login control will not work with Intelligencia.UrlRewriter

381 Views Asked by At

I hope someone can help me shed some light on this nightmare I'm having...!

I have just complete an ASP.Net e-commerce website with the help of an Apress book; The BalloonShop project, some of you might already know the one.

Everything is fine and dandy apart from one niggle that I cant seen to sort out!

I cannot logout from my site using the asp.net login control from any page that does not have the .aspx extension in the Url. This is namely; Departments, Category and Products as these are using the Intelligencia.UrlRewriter to provide browser friendly url's.

My url's are rewritten perfectly, but when I try to logout from a page that is using the url rewriter it does not work, and I receive the following message in my error log email:

Exception generated on 22 February 2013, at 22:23

Page location: /Triple-x/Dynamo-p4/?

<div id=":143">ProductId=4

Message: The HTTP verb POST used to access path '/Triple-x/Dynamo-p4/' is not allowed.

Source: System.Web

Method: System.IAsyncResult BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)

Stack Trace:

at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionSt    ep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)</div>

In my web.config if have:

<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,Intelligencia.UrlRewriter" />
</configSections>

<rewriter>
<!-- Rewrite department pages -->
<rewrite url="^.*-d([0-9]+)/?$" to="~/Catalog.aspx?DepartmentID=$1" processing="stop" />
<rewrite url="^.*-d([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentID=$1&amp;Page=$2" processing="stop" />
<!-- Rewrite category pages -->
<rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2" processing="stop" />
<rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2&amp;Page=$3" processing="stop" />
<!-- Rewrite product details pages -->
<rewrite url="^.*-p([0-9]+)/?$" to="~/Product.aspx?ProductId=$1" processing="stop" />
</rewriter>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
  <remove name="ScriptModule" />
  <!--<add name="ScriptModule" preCondition="managedHandler" />-->
</modules>
</system.webServer>

I am also using IIS7 on my local machine, and have read that this can sometimes be the cause re: AppPool version. I have tried changing this to Classic ASP as suggested, but this did not work for me!

Does anyone know if this is a common problem when hosting on local machine and using Intelligencia.UrlRewriter? Would this possibly not be an issue if hosting on a shared web hosting server?

If I'm way off the mark then please forgive my naivety, as I am still quite new to this, especially projects of this size.

Thanks for you help!!

1

There are 1 best solutions below

0
cagin On

If you want to use url rooting you can use this codes. I use it also an e-commerce project:

in Global.asax file :

    void Application_Start(object sender, EventArgs e)
    {
        if (RouteTable.Routes.Count <= 0)
        {
            RouteTable.Routes.Add("Urun", new Route("Urun/{category}/{name}/{prid}/{caid}", new PageRouteHandler("~/ProductDetail.aspx")));
            RouteTable.Routes.Add("Kategori", new Route("Kategori/{upper}/{name}/{caid}", new PageRouteHandler("~/Categories.aspx")));
            RouteTable.Routes.Add("Icerik", new Route("Icerik/{name}/{cpid}", new PageRouteHandler("~/ContentPage.aspx")));
        }
    }

And you can this codes wherever you want to give link:

 var param = new RouteValueDictionary
                                    {
                                        {"category", "Oyuncak"},
                                        {"prid", ((DiscountProductsResult) e.Item.DataItem).ProductId},
                                        {"name", ((DiscountProductsResult) e.Item.DataItem).UrlView.Replace(" ", "-")},
                                        {"caid", 0}
                                    };


VirtualPathData path = RouteTable.Routes.GetVirtualPath(null, "Urun", param);

And you can get querystring values like this:

 RouteData.Values["caid"]