-1

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.

4

1 に答える 1

2

App_code保護されたフォルダーであるため、コンテンツを直接要求する方法はありません。

代わりに、にあるクラスを利用する .cshtml ファイルを用意し、App_codeそれを Ajax 関数から呼び出す必要があります。Ajax 呼び出しに渡される URL は、単に .cshtml ファイルの URL です。パラメーターは、フォーム データ、クエリ文字列値、または UrlData として .cshtml ファイルに渡すことができます。

于 2012-10-30T09:09:09.293 に答える