2

I have many clients I want to give them scripts so I want to Create JS file based on their Cusotmer ID. So I can return and it directly execute on customer side. Client can be anyone either PHP,Html, ASP.net

Problem is when i browse this link it give me JS string but on customer side this script is not executing like for testing I put alert this alert is not showing on customer side


Customer

<head>
    <script src="http://localhost:12604/JSCreator/Handler.ashx?CustomerID=123" type="text/javascript"></script>
    <title></title>
</head>

Handler file

public class Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string CustomerId = context.Request["CustomerId"].ToString();
        string jscontent = JSFileWriter.GetJS(CustomerId); // This function will return my custom js string

        context.Response.ContentType = "text/javascript";
        context.Response.Write(jscontent);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}
1
  • Sorry :) I have updated now question Commented Jun 7, 2012 at 7:11

1 Answer 1

7

ContentType should be application/javascript

public void ProcessRequest(HttpContext context)
{
    string CustomerId = context.Request["CustomerId"].ToString();
    string jscontent = JSFileWriter.GetJS(CustomerId); // This function will return my custom js string

    context.Response.ContentType = "application/javascript";
    context.Response.Write(jscontent);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.