Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code:

[AcceptVerbs("GET")]
    [AllowAnonymous]
    [Route("ManageAccount/{id}")]
    public HttpResponseMessage ManageAccount(string id)
    {
        if (! String.IsNullOrEmpty(id))
        {

            var path = "C:/Users/user/Project/" + id + ".html";
            var response = new HttpResponseMessage();
            response.Content = new StringContent(File.ReadAllText(path));
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return response;
        }
        var path2 = "C:/Users/user/Project/Login.html";
        var response2 = new HttpResponseMessage();
        response2.Content = new StringContent(File.ReadAllText(path2));
        response2.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
        return response2;
    }



I set ContentType to be text/html to read html page, but this page has scripts, now all scripts read as text/html !

What I have tried:

[AcceptVerbs("GET")]
    [AllowAnonymous]
    [Route("ManageAccount/{id}")]
    public HttpResponseMessage ManageAccount(string id)
    {
        if (! String.IsNullOrEmpty(id))
        {

            var path = "C:/Users/user/Project/" + id + ".html";
              var response = new HttpResponseMessage();
                response.Content = new StringContent(File.ReadAllText(path));
                response.Content.Headers.ContentType = new 
                MediaTypeHeaderValue("text/html");
              response.Headers.Add("Accept-Ranges", "bytes");
                return response;
        }
        var path2 = "C:/Users/user/Project/Login.html";
        var response2 = new HttpResponseMessage();
        response2.Content = new StringContent(File.ReadAllText(path2));
        response2.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
        return response2;
    }



How can I fix this ????
Scripts from cdn work just fine but I need my scripts
I got that if scripts loaded in server it work !
So, what can I do?
Posted
Updated 12-Apr-19 12:29pm
v7

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900