【发布时间】:2015-09-04 22:41:20
【问题描述】:
我有问题。当我尝试从 MVC 操作将用户重定向到非 http URL 时,它返回:
对象已移至此处。
完整响应(来自 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 to <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>
我的操作(带有伪代码):
[HttpGet]
public ActionResult Consultation(int id)
{
//.. specific business logic
if(IsMobile()){
return RedirectPermanent("myGame-app://test.somespecificdata");
}
else{
return View("AboutGame", SomeSpecificModel);
}
}
同样的情况是return Redirect()而不是return RedirectPermanent()。
我的主要目标是将使用移动浏览器的用户重定向到具有特殊协议(不是 http)的 URL。这个特殊协议 (myGame-app://) 运行我的移动应用程序according to this Stack discussion。在没有信息Object moved to here的情况下如何实现这一点?
问候
【问题讨论】:
标签: c# asp.net .net asp.net-mvc asp.net-mvc-3