Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Composite C1 Routing with optional parameter on root page

$
0
0
Hi @brentsoftware

The C1PageRoute.RegistrePathInfoUsage() functionality isn't supported for the root "/" page.
The easiest way to make a feature, would be to write and register in web.config an HTTP module, that would check check if the request is coming to username link, and does a URL rewrite to a link, where the name is passed with query string. Or you can save the user name in HttpContext.Items instead, and rewrite to "/"


Something like this:


public class UserNameRewriteModule: IHttpModule
{
    public void Init(HttpApplication context)
    {
        context.BeginRequest += OnBeginRequest;
    }

    private void OnBeginRequest(object sender, EventArgs args)
    {
        var context = ((HttpApplication) sender).Context;

        string rawUrl = context.Request.RawUrl;

    // insert some proper check here
        if (rawUrl != "/username")
        {
            return;
        }

        context.RewritePath("/?user=username");
    }

    public void Dispose()
    {
    }
}

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>