0

サーバー ファイル (.asmx) とクライアント インターフェイス (.aspx) を含む .NET で Web サービスを実行しています。訪問者は、クライアント aspx サイト (urlXXX:portYY/Client.aspx) のみにアクセスできる必要があります。ただし、URL から「/Client.aspx」の部分を削除すると、プロジェクト ディレクトリにアクセスできなくなります。 . (これまでのところ、私は localhost だけでプロジェクトを実行しています。)

ソリューションの他の部分へのアクセスを制限する方法はありますか? 私が考えることができる唯一の可能性は、クライアント aspx サイト用に別のプロジェクトを作成することですが、それでも訪問者はそのサイトを含むディレクトリに入ることができます。

4

2 に答える 2

1

web.config を使用して明示的なアクセスを制御できるはずです。この例を見てください (エクスクレーマー:この MS ページから直接コピーしました):

<configuration>
    <system.web>
        <authentication mode="Forms" >
            <forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
            </forms>
        </authentication>
<!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
        <authorization>
            <deny users="?" /> 
        </authorization>
    </system.web>
<!-- This section gives the unauthenticated user access to the Default1.aspx page only. It is located in the same folder as this configuration file. -->
        <location path="default1.aspx">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
<!-- This section gives the unauthenticated user access to all of the files that are stored in the Subdir1 folder.  -->
        <location path="subdir1">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
</configuration>

編集:明示的なフォルダーへのアクセスを拒否する方法の詳細については、この質問をご覧ください。

于 2013-07-11T08:14:47.723 に答える