Tôi gặp sự cố. Khi tôi cố gắng chuyển hướng người dùng đến URL không phải http từ hành động MVC, nó trả về:Trả lại chuyển hướng "Đối tượng được chuyển đến"
Đối tượng được chuyển đến đây.
đáp ứng đầy đủ (từ 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>
hành động của tôi (với mã giả):
[HttpGet]
public ActionResult Consultation(int id)
{
//.. specific business logic
if(IsMobile()){
return RedirectPermanent("myGame-app://test.somespecificdata");
}
else{
return View("AboutGame", SomeSpecificModel);
}
}
Tình hình tương tự là với return Redirect()
thay vì return RedirectPermanent()
.
Mục tiêu chính của tôi là chuyển hướng người dùng sử dụng trình duyệt trên điện thoại di động tới URL có giao thức đặc biệt (không phải http). Giao thức đặc biệt này (myGame-app://
) chạy ứng dụng di động của tôi according to this Stack discussion. Làm thế nào tôi có thể đạt được điều này, mà không có thông tin Object moved to here
?
Kính trọng