Hi All,

I have enabled the 301 redirect on IIS 6 for my old site,the option for passing the query string is enabled in the IIS as mentioned in this article.

http://www.developerfusion.com/code/4678/permanent-301-redirect-with-querystring-in-iis/

My old site is webforms based while my new site is asp.net mvc 3 based.

I get the query string on the redirected site,but having problem for one specific url redirect.

The redirection for this link http://oldsite.com/blog/123-this-is-a-title.aspx goes to
http://newsite.com/blogpost.aspx?blogpostid=888&/blogpost.aspx.I loose the title from my old site.

I need the title of the post from the old site to come in my new site in the url,so that the custom route in my asp.net mvc apps can read the title from the url and get the blog post id for the title.

Please let me know why i am not getting the title of the post on my new site when redirect happens and how to get the title from the old url to my new sites url.

Thanks.
S.

Dani AI

Generated

The thread shows that enabled IIS6 301s with “append query string” but the legacy slug is still getting lost — example:
old URL /blog/123-this-is-a-title.aspx → newsite.com/blogpost.aspx?blogpostid=888&/blogpost.aspx.I. That pattern usually means IIS is tacking leftover path-info onto the destination (so the slug never ends up where the MVC route expects it). ’s pointer to doing the 301 in ASP.NET is useful: an application-level redirect or a small legacy handler is more reliable than the IIS redirect UI for preserving and shaping the final URL.

A simple, robust fix on the legacy WebForms app is to detect the old pattern and issue a precise 301 to the new canonical URL (build the slug exactly how the MVC routes expect it). Example Global.asax BeginRequest:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    var req = HttpContext.Current.Request;
    var m = System.Text.RegularExpressions.Regex.Match(req.Url.AbsolutePath, @"^/blog/(\d+)-([^.]+)\.aspx$", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    if (m.Success)
    {
        var id = m.Groups[1].Value;
        var slug = m.Groups[2].Value;
        var newUrl = string.Format("http://newsite.com/blog/{0}-{1}", id, slug); // adjust to MVC route format
        var res = HttpContext.Current.Response;
        res.Clear();
        res.StatusCode = 301;
        res.Status = "301 Moved Permanently";
        res.AddHeader("Location", newUrl);
        res.End();
    }
}

If changing the old site is not possible, handle the legacy request on the MVC side: map /blogpost.aspx (or check Request.RawUrl/QueryString) to a small action that reads blogpostid, looks up the title, composes the canonical slug URL and issues RedirectPermanent(...). That guarantees a clean SEO-friendly URL even when IIS mangles the incoming request.

Troubleshooting notes: capture the raw redirect with curl/Fiddler to inspect the Location header, log Request.RawUrl/ServerVariables["QUERY_STRING"] on the MVC side to see what arrived, and avoid redirect chains (legacy → blogpost.aspx → canonical). If the IIS redirect option that appends path-info is enabled, disable it or switch to an app-level approach for precise control.

Member Avatar for Member #949455

Please let me know why i am not getting the title of the post on my new site when redirect happens and how to get the title from the old url to my new sites url.

You can take a look at this:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.