I am posting some things to the database via AJAX and the C# code in the App_Code folder in my ASP.NET WebPages website is what will be doing this.
My question is, what do I use as the file path for the ajax part?
xmlhttp.open("POST", "App_Code/MyClass/MyMethod()");?
Obviously this doesn’t work since it’s wrong, but I cannot find any sources to confirm how to do this. I know it can be done because I found a code sample on SO months ago, but I can no longer find it.
There is no way to directly request contents in
App_codesince it’s a protected folder.Instead you should have a .cshtml file that makes use of your class located in the
App_codeand then call that from your Ajax function. The URL passed to the Ajax call is simply that of the .cshtml file. You can pass parameters to the .cshtml file as form data, query string values or as UrlData.