私はMVCを使用した.NETプロジェクトで作業しており、同じページのセクションを指すリンクを作成する必要があります。MVCページ内のリンク
次のコードは、MVCなしでうまく機能:
<a href="#section1">Section 1</a>
<div id="section1">
<h1>Section 1</h1>
</div>
今これは私の本当のURLです: http://localhost:17338/MarketingCustomers/CleanData/1/1150119
そして私はURLので、ID = customerErrorSectionとdiv要素にリンクできるようにする必要があります次のようになります。 http://localhost:17338/MarketingCustomers/CleanData/1/1150119#customerErrorSection
URLの末尾に「#customerErrorSection」を追加する必要があります。
しかし、MVCのルーティングは、これは動作していない私のコードで、私はRouteConfigで遊んでてきたが、私は、私は必要なURLを作成する方法がわからない http://localhost:17338/MarketingCustomers/CleanData/1/1150119#/customerErrorSection
にURLを変更します。
routes.MapRoute(
name: "MarketingDataClean_CustomerErrorSection",
url: "MarketingCustomers/CleanData/{systemSourceId}/{systemSourceCustomerId}/{#customerErrorSection}",
defaults: new { controller = "MarketingCustomers", action = "CleanData", systemSourceId = "", systemSourceCustomerId = "" }
);
ありがとうございました!
URLの '# '部分はサーバー側に届くべきではないので、それをルートに追加する必要はありません –