Link to home
Start Free TrialLog in
Avatar of Starr Duskk
Starr DuskkFlag for United States of America

asked on

Short URL suggestions

My client wants a url like this:

http://mywebsite.com/NameofClient

I use ASP.NET WEBFORMS, so please no MVC answers.

If I do:

http://mywebsite.com/NameofClient

It expects that to be a folder name and errors.

If I do it with the ? it works:
http://mywebsite.com?NameofClient

But the client says ?'s are too confusing.

Any suggestions?

Can this be done with MapHttpRoute in the global.asax and then redirect to the page I want?
Avatar of ste5an
ste5an
Flag of Germany image

Well, when this is the complete requirement, then a URL rewrite from http://mywebsite.com/NameofClient to http://mywebsite.com?NameofClient should do the job.

I use ASP.NET WEBFORMS, so please no MVC answers.
They can coexist and you can use both in parallel. So using MVC for the routing and web forms for the rest is possible (samples on EE andsample).
Avatar of Starr Duskk

ASKER

ste5an,

I'll check into that.

the "samples on ee" link is broken.
stefan,

I tried the below in my web.config

    <rewrite>
      <rules>
        <rule name="Launch URL Redirect" stopProcessing="true">
          <match url="/bsar" />
          <action type="Redirect" url="/mysubdir/Launch.aspx" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>

Open in new window


And it still pulls up the 404 built-in error, instead of a custom error page or redirecting.

how do I do the match url as a wild card type of thing? that if it contains /bsar

And also is my url correct? or does it need a tilde? will it do relative redirects?

I am running this from localhost right now.

Thanks!
This is probably overkill, but you can write your own ISAPI.

https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524338(v%3Dvs.90)
Creating ISAPI Extensions
	if (urlString.Find("YourTrigger") != -1) //we want to redirect this file
    {
        urlString.Replace("YourTrigger","NameofClient");
        char *newUrlString= urlString.GetBuffer(urlString.GetLength());
        pHeaderInfo->SetHeader(pCtxt->m_pFC, "url", newUrlString);
        return SF_STATUS_REQ_HANDLED_NOTIFICATION;
   }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Starr Duskk
Starr Duskk
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial