c# - Redirect returns "Object moved to" -


i have problem. when try redirect user non-http url mvc action, returns:

object moved here.

full response (from fiddler):

http/1.1 301 moved permanently cache-control: private content-type: text/html; charset=utf-8 location: mygame-app://test.somespecificdata server: microsoft-iis/8.0 x-aspnetmvc-version: 4.0 x-aspnet-version: 4.0.30319 x-sourcefiles: =?utf-8?b?qzpcvxnlcnncuglvdhjcrgvza3rvcfxuywtlc0nhcmvcvgfrzxndyxjlxervy3rvcnncrwrvy3rvclxdb25zdwx0yxrpb25cmtkx?= x-powered-by: asp.net date: thu, 18 jun 2015 18:19:35 gmt content-length: 457  <html><head><title>object moved</title></head><body> <h2>object moved <a href="mygame-app%3a%2f%2ftestprotocol.somespecificdata">here</a>.</h2>  <!-- visual studio browser link --> <script type="application/json" id="__browserlink_initializationdata">     {"appname":"firefox"} </script> <script type="text/javascript" src="http://localhost:53098/4c9c75263d91451fa797f9041e4bd0f3/browserlink" async="async"></script> <!-- end browser link -->  </body></html> 

my action (with pseudo code):

[httpget] public actionresult consultation(int id) {       //.. specific business logic       if(ismobile()){           return redirectpermanent("mygame-app://test.somespecificdata");        }       else{           return view("aboutgame", somespecificmodel);       } } 

the same situation return redirect() instead of return redirectpermanent().

my main goal redirect user uses mobile browser url special protocol (not http). special protocol (mygame-app://) runs mobile app according stack discussion. how can achieve this, without information object moved here?

regards

the redirect/redirectpermanent methods add body response containing "moved here"-html. if want "empty" response set response yourself:

httpcontext.current.response.redirect("url", false); httpcontext.current.response.statuscode = 301; httpcontext.current.applicationinstance.completerequest(); 

be aware rest of logic after executed, make sure nothing else (filters etc) might redirect response again happens after setting this.


Comments

Popular posts from this blog

python - How to create jsonb index using GIN on SQLAlchemy? -

PHP DOM loadHTML() method unusual warning -

c# - TransactionScope not rolling back although no complete() is called -