tags:

views:

15

answers:

2

I have a handler CsvExport.ashx that resides in the root of my web application, the problem is it is called from a javascript include so I can't use ~/ how can i have it so that any call to a file name CsvExport.ashx in in folder in the web application get sent to the proper file?

A: 

A slash by itself represent the root folder, so call it like this:

/CsvExport.ashx 

No need for the ~

Ray
the problem is one some servers the webapplication is at http://server1/ and on some it is at http://server2/~sitename/
Christopher Kelly
A: 

I would put a client-side script block in your web page or master page that contains a variable that your JavaScript includes can use, like so:

<script type="text/javascript">
    var handlerPath = "<%=ResolveUrl('~/CsvExport.ashx')%>";
</script>

You can then include your other JS files that need this path after this script block. This ensures that no matter where you are in your web application, the path variable will always point to the root of your web app.

Tim S. Van Haren
this would work, i would have to update several pages, but it is an option
Christopher Kelly