本文实例讲述了ASP.NET中Global和URLReWrite用法。分享给大家供大家参考。具体如下:
Global.asax:
有时候叫做 ASP.NET 应用程序文件,提供了一种在一个中心位置响应应用程序级或模块级事件的方法。你可以使用这个文件实现应用程序安全性以及其它一些任务。
重点了解:application_Start; application_BeginRequest; application_Error;
① application_Start:自从服务器启动起来,网站第一次被访问的时候Application_Start执行
② Application_Error :程序中发生未处理异常
③ Session_End:只有进程内的Session才会调用,session_End进程外的Session不会
④ application_BeginRequest:当一个请求过来的时候,便会调用application_BeginRequest,访问静态页面时application_BeginRequest不会处理,IIS直接将静态页面文件给了浏览器。即使访问一个不存在的页面,Application_BeginRequest方法也会被调用。
URLReWrite:
丑链接:http://localhost/viewPerson.aspx"/ViewPerson.aspx" + id); 搞定,整成【帅链接】,就这么简单。
使用正则表达式:
protected void Application_BeginRequest(object sender, EventArgs e) { Match match = Regex.Match(Context.Request.Path, @"^/ViewPerson\-(\d+)\.aspx$"); if (match.Success) { string id = match.Groups[1].Value;//拿到(\d+)就是id 的值 Context.RewritePath("/ViewPerson.aspx" + id); } }
希望本文所述对大家的asp.net程序设计有所帮助。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】