Search code examples
javascriptjqueryasp.netashx

how to get Physical path of working folder in javascript or jquery?


How to get Physical path of working folder in jscript or jquery?

What i need is when a dropdown is selected or if a button is clicked i need to get complete path of the working folder.

ex:

var x="path" here x should be  x=E:/projects/projectname/xyz.aspx.  

i dont want url of current docuent, i want complete path, so that i can generate new aspx page and place in that folder dynamically.


Solution

  • I think you are looking for something like this:

    var x = ('<%=HttpUtility.JavaScriptStringEncode(Server.MapPath(Request.Url.LocalPath))%>');
    

    Now, how useful is that information on the client side is something that's not clear to me, besides being risky, in my opinion...

    On my PC, it prints this if I do console.log(x):

    \\company\home_drives$\rsanchez\visual studio 2012\Projects\test\test\Default.aspx