Nagma Khan

Nagma Khan

  • NA
  • 126
  • 22.8k

how to redirect to html page in my web api post method

Oct 24 2017 7:36 AM
I want to give web API to the user fro particular time only such as if I give the hosted link of web API to the client then it should be accessed for 15 days only for that, I have Added startDate and EndDate Column in my Registration table whenever the user logged in the date of logged in gets save in database I will define EndDate Manually in database
  1. [HttpPost]  
  2. public void PostInsertDate([FromBody]ExpoRegistration ExpoRegistration)  
  3. {  
  4. //string remoteUrl = "http://localhost:64995/Data.html";  
  5. Big5OnlinePortalEntities db = new Big5OnlinePortalEntities();  
  6. var date = db.ExpoRegistrations.FirstOrDefault(e => e.UserName == ExpoRegistration.UserName && e.Password == ExpoRegistration.Password);  
  7. if (date.StartDate == null)  
  8. {  
  9. date.StartDate = DateTime.Today.Date;  
  10. DateTime edate = date.StartDate.Value.AddDays(15);  
  11. date.EndDate = edate;  
  12. db.SaveChanges();  
  13. Request.CreateResponse(HttpStatusCode.OK, date);  
  14. }  
  15. else  
  16. {  
  17. Get();  
  18. //Redirect(remoteUrl);  
  19. //Request.CreateErrorResponse(HttpStatusCode.NotFound, "Customer not found");  
  20. }  
  21. if (date.StartDate >= date.EndDate)  
  22. {  
  23. Request.CreateErrorResponse(HttpStatusCode.NotFound, "Customer not found");  
  24. }  
  25. else  
  26. {  
  27. Get();  
  28. //Redirect(remoteUrl);  
  29. //var response = new HttpResponseMessage(HttpStatusCode.Redirect);  
  30. //response.Headers.Location = new Uri("http://localhost:64995/Data.html");  
  31. }  
  32. }  
  33. public HttpResponseMessage Get()  
  34. {  
  35. var response = Request.CreateResponse(HttpStatusCode.Found);  
  36. response.Headers.Location = new Uri("http://localhost:64995/Data.html");  
  37. return response;  
  38. }  
  39. }  
In above code, everything is working well. The problem is with redirect of page data.html
 
why it is not redirecting to it 
 
Thanks!! 

Answers (1)