One method in my controller returns a view which has link like http://localhost:17000/Questionnaire/CompleteQuestionnaire?GuidToken=4815823D-3BFF-487D-AEB0-BB874AE9FBDE
and other method returns just link like /Questionnaire/CompleteQuestionnaire?GuidToken=4815823D-3BFF-487D-AEB0-BB874AE9FBDE
[HttpGet]
public JsonResult ShowUrlQuestionnaire(int id)
{
var questionnaire = QuestionnaireRepository.GetById(id);
var questionnaireUrl = "/Questionnaire/CompleteQuestionnaire?GuidToken=" + questionnaire.QuestionnaireId.ToString();
return Json(questionnaireUrl, "text/html", System.Text.Encoding.UTF8,
JsonRequestBehavior.AllowGet);
}
how can I add root part of link in var questionnaireUrl
?
I tried to add this method in controller
private string GetBaseUrl()
{
var request = HttpContext.Current.Request;
var appUrl = HttpRuntime.AppDomainAppVirtualPath;
if (!string.IsNullOrWhiteSpace(appUrl)) appUrl += "/";
var baseUrl = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Url.Authority, appUrl);
return baseUrl;
}
but I got error
Error 1 'System.Web.HttpContextBase' does not contain a definition for 'Current' and no extension method 'Current' accepting a first argument of type 'System.Web.HttpContextBase' could be found (are you missing a using directive or an assembly reference?)
How to fix it?