Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'System.Web.HttpRequestBase' to 'Microsoft.AspNet.Http.HttpRequest' Sports_ C:\Users\Andrew\Documents\Visual Studio 2015\My Projects\Sports_ - Copy - Copy\Sports_\Views\_ViewStart.cshtml 4 Active
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Hello Yuki, i added the code snippet as you directed. And it cleared the erro. But now i get an exception from the _Layout method? I dont quite understand can you help?? Markus.
{"The layout page \"_Layout\" could not be found at the following path: \"~/Views/_Layout\"."}
Member
251 Points
423 Posts
Http Extensions Error!
Nov 12, 2018 10:00 PM|Markus33|LINK
Is their anyway possible to clear the following error? Markus
ViewStart.cshtml
{
if (Context.Request.Headers["X-Requested-With"] == "XMLHttpRequest")//if ajax request
{
Context.Response.Headers["Location"] = Microsoft.AspNet.Http.Extensions.UriHelper.GetDisplayUrl(Context.Request); //RawUrl
Context.Response.Headers["Cache-Control"] = "no-store";//context.HttpContext.Response.Cache.SetNoStore(); //stop caching(partial content) on client's browser
}
else
{
Layout = "_Layout";
}
}
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'System.Web.HttpRequestBase' to 'Microsoft.AspNet.Http.HttpRequest' Sports_ C:\Users\Andrew\Documents\Visual Studio 2015\My Projects\Sports_ - Copy - Copy\Sports_\Views\_ViewStart.cshtml 4 Active
Contributor
3710 Points
1431 Posts
Re: Http Extensions Error!
Nov 13, 2018 04:16 AM|Yuki Tao|LINK
Hi Markus33,
Actually,I don't know what you want clearly.
And this library Microsoft.AspNet.Http.Extensions is old version.
I suggest you could try to code like:
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
251 Points
423 Posts
Re: Http Extensions Error!
Nov 13, 2018 06:38 PM|Markus33|LINK
Hello Yuki, i added the code snippet as you directed. And it cleared the erro. But now i get an exception from the _Layout method? I dont quite understand can you help?? Markus.
{"The layout page \"_Layout\" could not be found at the following path: \"~/Views/_Layout\"."}
@{if (Context.Request.Headers["X-Requested-With"] == "XMLHttpRequest")//if ajax request
{
Context.Response.Headers["Location"] = Request.RawUrl; //RawUrl
Context.Response.Headers["Cache-Control"] = "no-store";//context.HttpContext.Response.Cache.SetNoStore(); //stop caching(partial content) on client's browser
}
else
{
Layout = "_Layout"; //program throws exception here.
}
}
All-Star
48320 Points
18008 Posts
Re: Http Extensions Error!
Nov 13, 2018 06:56 PM|PatriceSc|LINK
Hi,
Where is your _Layout.cshtrml file ? Usually this is Layout="~/Views/Shared/_Layout.cshtml"; (and the file is in the corresponding folder).
See https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/introduction/adding-a-view#changing-views-and-layout-pages