locked
Http Request Error. RRS feed

  • Question

  • User1421620300 posted

    This is a particular situation that i have. My code is being used from a tutorial to do a conversion in a ASP.Net application that works on MVC. But i am trying to transfer some code from a .Net Core project in hopes that it would run. Only one thing is the single error inside of Viewstart. I am quite sure that this error can be fixed due to its not being so problematic. If someone who knows this can explain please do? Markus.

    SEE: RedLine, Line 4

    Server Error in '/' Application.


    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0234: The type or namespace name 'Http' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

    Source Error:

    Line 2:      if (Context.Request.Headers["X-Requested-With"] == "XMLHttpRequest")//if ajax request
    Line 3:      {
    Line 4:          Context.Response.Headers["Location"] = Microsoft.AspNet.Http.Extensions.UriHelper.GetDisplayUrl(Context.Request);//RawUrl
    Line 5:          Context.Response.Headers["Cache-Control"] = "no-store";//context.HttpContext.Response.Cache.SetNoStore(); //stop caching(partial content) on client's browser
    Line 6:      }

    Saturday, November 10, 2018 7:04 PM

Answers

  • User-271186128 posted

    Hi Markus33,

    Compiler Error Message: CS0234: The type or namespace name 'Http' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

    From the error message, it seems that the Microsoft.AspNet hasn't installed for the application.

    As far as I know, the Microsoft.AspNet.Http.Extensions is used in the asp.net 5 application, if you want to use the UriHelper in asp.net core application, we could use the Microsoft.AspNetCore.Http.Extensions. Please check the reference(dependencies), and make sure you have installed the right version.

    Best regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 12, 2018 6:22 AM