對指定磁碟檔案路由,而對其他磁碟檔案不路由

2022-04-05 03:12:50 字數 1409 閱讀 9435

public

static

void

registerroutes(routecollection routes)

,new );

routes.maproute(

"myroute

", "

///"

,

new ,

new ,

new );

}

因為開啟了routes.routeexistingfiles = true;表明對磁碟檔案都要進行路由,但是下面的路由匹配中,對磁碟檔案只有乙個靜態匹配,也就是說只有使用chrome瀏覽器對於"~/content/staticcontent.html"的訪問才會匹配到第乙個定義的路由,路由到accountcontroller的logon方法上。

考慮這樣的情況:在當前專案(11-3urltestdemo)的content檔案上add->new item->visual c#->web->html page,新建乙個hello.html的檔案:

<

html

>

<

head

>

<

title

>hello

title

>

head

>

<

body

>

<

h2>hello,the world.

h2>

body

>

html

>

執行程式,如果發起對"~/content/hello.html"的訪問,資料上給出的說明是第乙個路由不匹配,會匹配第二個路由,也就是將controller匹配為content,將action匹配為hello.html,由於沒有這樣的控制器和方法,所以會給出404錯誤。但實際在實驗時,發現這種情況仍然訪問到的是hello.html檔案,是否在mvc3中匹配後如果都沒有匹配,會自動去尋找有沒有該磁碟檔案?

按原意,如果因為去匹配控制器和動作方法導致hello.html無法訪問,解決的方法是設定routes.ignoreroute繞過路由。例如:

public

static

void

registerroutes(routecollection routes)

,new );

routes.ignoreroute(

"content/.html");

routes.maproute(

"myroute

", "

///"

,

new ,

new ,

new );

}

-lyj

對磁碟檔案的I O操作

要使用utl file包首先需要設定utl file dir引數,方法如下 以sys使用者登陸後執行以下步驟 1 create or replace directory directory as pathname 建立目錄 2 grant read,write on directory tmp to...

備份VMware虛擬磁碟檔案 移植到其他虛擬機器

原文 第一種方法 直接複製本地主機磁碟下的虛擬磁碟檔案到備份目錄中,下次恢復時,直接用vmware開啟備份目錄下的檔案即可。首先,開啟vmware虛擬機器,滑鼠放到需要備份的vmware機名稱前,會顯示此虛擬機器虛擬磁碟檔案及配置檔案所存放的目錄。進入到虛擬磁碟及配置檔案所在目錄,複製所有檔案到備份...

關於檢視指定磁碟目錄下資料夾及其檔案的辦法

public class test1 else system.out.println s file1.getname public static void main string args 一 通過file類物件的listfiles方法,將路徑 d downloads 下的所有目錄及檔案物件賦給了f...