国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
asp.net 用偽靜態(tài)

    使用rewrite在iis上設(shè)置規(guī)則來(lái)實(shí)現(xiàn)偽靜態(tài),這樣在vs中開(kāi)發(fā)的時(shí)候?qū)o(wú)法調(diào)試,必須要是用iis發(fā)布才不會(huì)造成找不到文件的錯(cuò)誤,當(dāng)然,肯定還有其他的方法來(lái)實(shí)現(xiàn)偽靜態(tài)的,不用再iis中設(shè)置任何的東西,只需要一個(gè)。net的組件和設(shè)置一下webconfig文件就ok了,來(lái)看一下,這東西,我用的次數(shù)很少,每次用都怕忘記,所以記錄下來(lái),下次忘記的話也不用Google啦

      這回的準(zhǔn)備工作,你必須去網(wǎng)上download一個(gè)URLRewriter.dll組件了,網(wǎng)上貌似有這個(gè)類(lèi)庫(kù)的源代碼,當(dāng)然里面也有編譯好的dll文件,只需要把dll文件coty到自己站點(diǎn)的Bin下面,然后在網(wǎng)站上右鍵,添加引用,瀏覽選擇這個(gè)dll文件即可。

     下面就需要在webconfig里面配置一番了

     1、在Web.Config的<system.web>和</system.web>添加以下節(jié)點(diǎn):
    <httpModules> 
      <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" /> 
    </httpModules> 

    2、在Web.Config的<configuration>和</configuration>添加以下節(jié)點(diǎn):

<configSections> 
  <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" /> 
</configSections> 
   
 <RewriterConfig>
  <Rules>
   <RewriterRule>
    <LookFor>~/Default/.html</LookFor>
    <SendTo>~/Default.aspx</SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/Detial_([0-9]*)/.html</LookFor>
    <SendTo>~/Detial.aspx?Id=$1</SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/List_p([0-9]*)/.html</LookFor>
    <SendTo>~/List.aspx?page=$1</SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/Double_t([0-9]*)_p([0-9]*)/.html</LookFor>
    <SendTo><!--[CDATA[~/Double.aspx?type=$1&page=$2]]--></SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/About_(.*)/.html</LookFor>
    <SendTo>~/About.aspx?title=$1</SendTo>
   </RewriterRule>
  </Rules>
 </RewriterConfig>

設(shè)置完以上兩個(gè)步驟,就基本可以運(yùn)行了,其中<RewriterRule/>標(biāo)簽里面就是重寫(xiě)的一個(gè)模塊,<LookFor/>里面的是重寫(xiě)后的地址,而<SendTo/>則是原地址。大家應(yīng)該注意到了我寫(xiě)了2組<RewriterRule/>,其中第一組的是給單參數(shù)的地址用的,而另一組是給多參數(shù)動(dòng)態(tài)文件用的。

   相信大家如果用過(guò)在iis里面配置偽靜態(tài)規(guī)則的話,那在webconfig里面配置規(guī)則自然不在話下,如果不會(huì)的話,就去找一些正則表達(dá)式的書(shū)看一下,不需要很精通就行

  當(dāng)然此方法有一些注意事項(xiàng):
1.不能使用Windows身份驗(yàn)證用戶權(quán)限. 應(yīng)使用Form驗(yàn)證,在web.config配置為:<authentication mode="Forms" />
2.使用Request.ServerVariables["script_name"]獲得的路徑仍然是:ShowPlay.asp?vid=1
3.被重寫(xiě)的地址如果回發(fā),重寫(xiě)將失效 顯示的地址將是ShowPlay.asp?vid=1
4. 后綴名必須為.aspx.如果是其他自定義后綴名,如.net  請(qǐng)?jiān)趇is將.net映射到aspnet_isapi.dll.

 

五個(gè)頁(yè)面

About.aspx

    <form id="form1" runat="server">        <div>    這是Aboutl頁(yè),url是About.aspx還是About.html?<br/>        <br/>    <br/>    <a href="Default.html" mce_href="Default.html">主頁(yè)</a>    <br />    <br />    <a href ="List_p1.html">List頁(yè)傳page參數(shù)</a>    <br />    <br />    <a href ="Detial_1.html">Detial頁(yè)傳值Id參數(shù)</a>        <br />    <br />    <a href ="About_jianjie.html">About頁(yè)傳值title參數(shù)</a>       <br />    <br />    <a href ="Double_t1_p1.html">Double頁(yè)傳值type和page參數(shù)</a>         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>    </div>    </form>

cs代碼:

//About頁(yè)面public partial class About : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string title = Request["title"].ToString();        TextBox1.Text = "name為" + title;    }}//Detial頁(yè)面public partial class Detial : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string Id = Request["Id"].ToString();        TextBox1.Text = "Id號(hào)為" + Id;    }}//Double.aspx頁(yè)面public partial class Double : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string type = Request["type"].ToString();        string page = Request["page"].ToString();        TextBox1.Text = "type為:" + type + "page為" + page;    }}//List.aspx頁(yè)面public partial class List : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string page = Request["page"].ToString();        TextBox1.Text = "頁(yè)數(shù)為" + page;    }}

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
ASP.NET網(wǎng)站偽靜態(tài)下使用中文URL的方法
在 ASP.NET 中執(zhí)行 URL 重寫(xiě)
NET中關(guān)于偽靜態(tài)的實(shí)現(xiàn)方法
.net實(shí)現(xiàn)URL重寫(xiě),偽靜態(tài)。IIS7直接支持重寫(xiě)模塊
偽靜態(tài)web.config配置步驟
使用Cross-Page Postback 頁(yè)面間傳值
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服