0

I am currently working on a project for which there exists both a mobile app and a web site. One task can be performed on either the web site (meant for desktop users) or the app. Right now, the requested functionality for the site is as follows:

  1. If a desktop user visits the web page, continue on that page as usual.
  2. If a mobile user visits the web page, redirect them to the installed mobile app.

I have already implemented logic to tell whether the user is on a desktop or mobile device (most of the time, at least); however, it occurred to me that some users may not have the app installed, or that a desktop device could be incorrectly identified as a mobile device in the future. If a computer that does not have the app installed is redirected, they will encounter some error or an about:blank page. So, my question is, is there any way to tell whether a Response.Redirect to a mobile app will succeed?

So far I have investigated the HttpWebRequest/HttpWebResponse option to try and determine success or failure based on a requested page response prior to the redirect, but this does not seem like a valid option since a URL linked to an app will not provide a valid URI for the HttpWebRequest to test with. Any assistance or advice would be greatly appreciated. Thank you!

For clarification, the redirect looks something like this:

Response.Redirect("opencustomapp://SomePage?Parameter1=bar&Parameter2=foo");

The expected result is not to open a web page, but rather to interact with an app installed on the user's phone which has been mapped to this url.

EDIT: I have accepted the answer that it does not seem possible to do what I was asking for, but in case others have this problem, I wanted to attach some useful links to other questions about how to use a cookie to determine if the app is installed and how to redirect the user to some other place if the cookie is not set. For my own code, I will probably be going with a combination of a user-agent check and the setTimeout() function, as this can be implemented from code-behind using ClientScript.RegisterStartupScript without requiring any changes to the existing app.

Community
  • 1
  • 1
user2912928
  • 170
  • 3
  • 15

1 Answers1

2

No, there is no way to tell at the server if the redirect would succeed. This is because the redirect is sent back to the client from your server and executed at the client. Probably the best thing that you can do is use the mobile app to set a cookie for the website on the device, and then check for that cookie on the server side of the request... if it exists, redirect. Be careful to clear the cookie if they delete the app (if possible, not super familiar with mobile apps), otherwise the redirect would fail.

Haney
  • 32,775
  • 8
  • 59
  • 68
  • 1
    Thank you for your suggestion! I will look into this. A solution that does not require any changes to the app would be ideal though, as I am not the developer for that component and may not be able to change it. I will leave the question open a little longer just in case. – user2912928 Dec 04 '13 at 20:38
  • No worries, though I have extensive experience in this field and don't know of any other possible way. Maybe a mobile developer could provide some feedback on whether or not this is possible client-side, however it would likely still require mobile app changes. – Haney Dec 04 '13 at 21:12