Reputation: 395
How can I have a dynamic URL in a new page generated by a Web API redirect??
public HttpResponseMessage Get(string id)
{
var URL = "myurl";
System.Web.HttpContext.Current.Response.Redirect("mypage.html");
}
<a href="{{myurl}}></a> ?????????????????? </body> </html>
Upvotes: 1
Views: 2733
Reputation: 171
[HttpGet]
public RedirectResult Get()
{
string URL ="MYPAGE.HTML";
return RedirectPermanent(URL);
}
I don't get what exactly want to do but if you want to redirect to specific Url then it can be achieved using this above way, but if you want to get url from the html then you need to pass Url as request param like below.
[HttpGet]
public RedirectResult Get(string downloadURL)
{
string redUrl="http://www.y.com/l.htm?"+downloadURL:
return RedirectPermanent(redUrl);
}
From above, response will be redirected to that destination html page with download link as query string and you can set download link in your html page by taking from query string.
Upvotes: 1
Reputation: 8263
this is another way to do it, hopefully my way can help you
private gigadeEntities1 db = new gigadeEntities1();
public IQueryable GetAll(string id)
{
switch(id)
{
case "travel":
return db.travel;
case "announce":
return db.announce;
}
return null;
}
Upvotes: 0
Reputation: 8263
I have the same ideas to do it ,so that I have tried to deal with this issue , hopefully my code can help you as following some methods
PS: one control to handle different web api Model
public class ff1Controller :BaseController<travel>
{
public ff1Controller()
{
}
}
public class ff2Controller : BaseController<a1>
{
public ff2Controller()
{
}
}
Upvotes: 0
Reputation: 161
It's not possible to get the variable generated in this way during a redirect. Are you sure, that you need this redirect?
Upvotes: 0