1

In my apphost.cs file I have defined unauthorized requests to open login.cshtml.

SetConfig(new EndpointHostConfig
{
   CustomHttpHandlers =
   {
      {HttpStatusCode.NotFound, new RazorHandler("NotFound")},
      {HttpStatusCode.Unauthorized, new RazorHandler("login")},
   }
 });      

I'm running the project self hosted. I have deployed the project to a server (Debian+Apache: ProxyPass to http://127.0.0.1:2008).

My problem is that the redirect link(querystring) links back to http://127.0.0.1:2008/People.

http://servername/login?redirect=http://127.0.0.1:2008/People

How can I override the redirect url to point to http://servername/People?

Fossmo
  • 2,862
  • 4
  • 25
  • 47

1 Answers1

1

Try specifying the server url you wish to use in your config, e.g:

SetConfig(new HostConfig { 
   WebHostUrl = "http://servername/"
});
mythz
  • 141,670
  • 29
  • 246
  • 390
  • This does not change the redirect URL. I need the URL to look like this: `http://servername/login?redirect=http://servername/People` – Fossmo May 27 '13 at 07:47
  • @mythz sorry this is an old question, but I'm seeing the same issue with haproxy in front of nginx/fastcgi. However the requested hostname comes through fine, but the private port is added onto the redirect. Is there any way to easily drop the port number, without hardcoding a WebHostUrl? (i'd like to still be able to hit servers individually for testing) I'm seeing this port being added for redirect to login when unauthorized, as well as in the continue url. e.g. http://myserver:1234/login?redirect=http://myserver:1234/home (neither "1234" should be there) – JesseP Sep 10 '15 at 16:50
  • @mythz, actually i stumbled across another question referencing overriding the ResolveAbsoluteUrl method, which did the trick for me: http://stackoverflow.com/questions/20061340/how-can-i-set-webhosturl-in-servicestack Still interested to hear if there are other ways to go about this that might be cleaner. Thanks! – JesseP Sep 10 '15 at 18:41