Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
how to redirect to html page in my web api post method
Nagma Khan
Oct 24 2017 7:36 AM
275
Reply
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
[HttpPost]
public
void
PostInsertDate([FromBody]ExpoRegistration ExpoRegistration)
{
//string remoteUrl = "http://localhost:64995/Data.html";
Big5OnlinePortalEntities db =
new
Big5OnlinePortalEntities();
var date = db.ExpoRegistrations.FirstOrDefault(e => e.UserName == ExpoRegistration.UserName && e.Password == ExpoRegistration.Password);
if
(date.StartDate ==
null
)
{
date.StartDate = DateTime.Today.Date;
DateTime edate = date.StartDate.Value.AddDays(15);
date.EndDate = edate;
db.SaveChanges();
Request.CreateResponse(HttpStatusCode.OK, date);
}
else
{
Get();
//Redirect(remoteUrl);
//Request.CreateErrorResponse(HttpStatusCode.NotFound, "Customer not found");
}
if
(date.StartDate >= date.EndDate)
{
Request.CreateErrorResponse(HttpStatusCode.NotFound,
"Customer not found"
);
}
else
{
Get();
//Redirect(remoteUrl);
//var response = new HttpResponseMessage(HttpStatusCode.Redirect);
//response.Headers.Location = new Uri("http://localhost:64995/Data.html");
}
}
public
HttpResponseMessage Get()
{
var response = Request.CreateResponse(HttpStatusCode.Found);
response.Headers.Location =
new
Uri(
"http://localhost:64995/Data.html"
);
return
response;
}
}
In above code, everything is working well. The problem is with redirect of page data.html
why it is not redirecting to it
Thanks!!
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
I want to fill dropdownlist from database in html page
Amadeus WebServices ...