0

I am working on an asp.NET 4.0 Web Application, using C#. I would like to redirect the user to the homepage of his browser. Is this possible?

This will be done because internally we are using an intranet, and we would like to make it redirect to that intranet without having to hard code it and since the homepage is by default the url of the intranet, it would be better if we could use the homepage instead of hardcoding it.

EDIT:

We are using IE here, and will not change most probably as that is the standard. So as long as it works with all IE Versions, it's fine.

Ryan S
  • 3,210
  • 17
  • 48
  • 79
  • Redirect to `about:home` (i think) – George Duckett Aug 24 '11 at 14:36
  • 2
    You can redirect to any page, but you can't retrieve the user home page because of Security and Privacy issues, why don't you just redirect to the intranet home ? –  Aug 24 '11 at 14:36
  • @George - Did not quite understand what you are saying, how would that redirect to the webpage stored as the homepage of your browser? – Ryan S Aug 24 '11 at 14:37
  • @Omeid Herat - So if it changes, we would not need to change anything. – Ryan S Aug 24 '11 at 14:37
  • @George: That works for IE, and some other browsers have a built-in "home page". It's not always the same as the home page specified by the user. – Yuck Aug 24 '11 at 14:37
  • @Ryan, sorry, looks like that advice was out-dated, just to work in an old version of IE – George Duckett Aug 24 '11 at 14:38
  • We are using IE7 at the time being, but don't want to limit it in case a browser comes out. So something general is much better, another alternative if this fails, is to make it get the URL from a Paramaters File. – Ryan S Aug 24 '11 at 14:40
  • 1
    @Ryan: then you will **just change to redirect to the new address** *instead of changing every machines home page.* –  Aug 24 '11 at 14:48
  • 1
    @Omeid Herat ftw that could be an entirely trivial operation with windows global policies + IE. – Chris Marisic Aug 24 '11 at 14:50

5 Answers5

3

Use Javascript to return to the user's home page,

e.g.

 function goHome(){
      if (window.home) { 
        window.home(); 
      } else { 
        window.location = "about:home"; 
      }
    }

and then call the JS goHome() function somewhere on the page (or even on a hyperlink).

Roy Goode
  • 2,940
  • 20
  • 22
1

As far as i know it is not possible (been researched alot). But if all homepages are the same why not simply use META REFRESH?

EDIT Try linking to this: About:home

<a href="About:home">Go home!</a>

worked for me in IE9

EDIT 2: Sending user to their browser's Home Page using Javascript This will get you started for firefox and safari

EDIT 3:

Response.Redirect("about:home", false);
Community
  • 1
  • 1
Luuk
  • 1,999
  • 3
  • 20
  • 27
1

As stated above, use the about:home uri.

Another solution would be to store the intranet url in the web.config and use this value. Then if it ever changes you will only need to change it in one place.

Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99
1

You Can't!

You can't retrieve the user home page because of Security and Privacy issues, and there is no Cross-browser work around.

What you can?

You can redirect to any page, so you can simply redirect to your intranet home page. its also more future proof so that if your intranet homepage changes you just have change to redirect to the new address instead of changing every single machines home page.

  • @james Johnson: *....an asp.NET 4.0 Web Application, **using C#.** I would like to redirect...* –  Aug 24 '11 at 15:21
  • @ James Johnson: and also none of the JS solutions out there is cross-browser. –  Aug 24 '11 at 15:25
  • JavaScript is an integral aspect of ASP.NET development, and is usable within ASP.NET, therefore it is a viable option. – James Johnson Aug 24 '11 at 15:29
  • You can also use Response.Redirect("about:home", false) too. Don't take it personal. I just have to vote down misinformation. – James Johnson Aug 24 '11 at 15:31
  • @James Johnson: its not about downvote, its about misinformation. 'about:home' is not cross-browser. –  Aug 24 '11 at 15:38
1

You cannot redirect server side to a users homepage.

SERVER <> USER (server is not the user)

Therefore the server cannot know what the user's homepage is.

So if you you use some sort of javascript redirect, then you sort of can redirect to home, but its a little glitchy.

All in all there is no cross-browser way to redirect to a user's homepage.

Naftali
  • 144,921
  • 39
  • 244
  • 303