3

Wants to convert the SharePoint requests to Lowercase in the IIS processing pipe line, it should not invoke additional request to change/convert the requested URL into lowercase but the same request should be converted.

The below IIS Rewrite Rule converts the URL which needs an additional request:

< rules>
< rule name="Convert to lower case" stopProcessing="false">
< match url=".[A-Z]." ignoreCase="false"/>
< conditions>
< add input="{URL}" negate="true" pattern="*lb-live.aspx$"/>
< /conditions>
< action type="redirect" url="{ToLower:{R:0}}" redirectType="Permanent"/>
< /rule>

Is there a way to simply convert the case while the request is being processed in IIS pipeline?

1 Answer 1

1

This requirement is very specific to your project. You can fulfil it by writing a HTTP Module which intercepts every SharePoint request, and converts it to Lowercase, see below:

public void Init(System.Web.HttpApplication Appl)
        {
            //Hookup the function that does the lowercase
            Appl.BeginRequest += new EventHandler(Appl_BeginRequest);
        }

void Appl_BeginRequest(object sender, EventArgs e)
        {
            System.Web.HttpApplication myAppl = (System.Web.HttpApplication)sender;
            string requestUrl = myAppl.Request.Url.PathAndQuery.ToLower();

            //additional checks on url
            if (requestUrl.Contains("test"))
            {

            }
        }

For addtional help, please see this link: Support for URL rewriting?

4
  • Is that mean that we can simply change the case while the request is in the IIS pipeline?...have gone through many articles however seems that we can only change and place a new request using the "Rewrite" method...? Jun 4, 2012 at 13:52
  • Every request goes through Application_BeginRequest anyway. You'll need to add some logic there. see my updated response. Jun 4, 2012 at 14:21
  • thanks for the code sample. Simply wants to convert the case on the IIS Request pipeline, how Could I achieve this without a redirection or placing another request... Jun 6, 2012 at 11:35
  • AFAIK, it is not possible without placing an another request. Jun 7, 2012 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.