0

私はこのコードを持っています

<script type="text/javascript">
    $(function () {

        var selectedAmenities = "";

        function amenitiesLog(message) {
            $("<div/>").text(message).appendTo("#amenitiesLog");
            $("<br/>").text("").appendTo("#amenitiesLog");
            $("#amenitiesLog").scrollTop(0);

            selectedAmenities = document.getElementById("amenitiesLog").innerHTML;
        }

        $("#Amenities").autocomplete({
            //source: "/Results/GetAmenities",
            source: function (request, callback) {
                var url = "/Results/GetAmenities?selected=" + selectedAmenities + '&term=' + request.term;
                $.getJSON(url, callback);
            },
            minLength: 3,
            select: function (event, ui) {
                if (ui.item != null)
                    amenitiesLog(ui.item.value);
            }
        });
    });
</script>​​​​​

これにより、この URL が生成されて呼び出されます

http://localhost:63320/Results/GetAmenities?selected=%3Cdiv%3EAir%20conditioning%3C/div%3E%3Cbr%3E&term=abc

Firebugで発生するエラーはこれです

A potentially dangerous Request.QueryString value was detected from the client (selected=&quot;&lt;div&gt;Air conditionin...&quot;).

解決策は何ですか?

ありがとう、

サチン

4

1 に答える 1

1

かつてこれに似たことがあり、無効な URL 文字が何であるかを宣言する必要がありました。私は自分のWeb設定でこれを次のように行いました:

<system.web>
    <httpRuntime requestValidationMode="2.0" executionTimeout="600" requestPathInvalidCharacters="&lt;,&gt;,*,%,\" relaxedUrlToFileSystemMapping="true" />
</system.web>

「requestPathInvalidCharacters」には無効な文字が含まれていたため、私の場合は、URL でコロンが必要になったため、コロンを削除しました。

これは私にとってはうまくいきましたが、ここで考える必要のあるセキュリティリスクがあるかどうかはわかりません.

于 2012-09-03T16:10:07.140 に答える