URL


.NET Core WebUtility.UrlEncode or HttpUtility.UrlEncode

When we are dealing with URL encode in .NET Core 2.1, there are two APIs: System.Net.WebUtility.UrlEncode and System.Web.HttpUtility.UrlEncode. What's the difference between them? And which one should we prefer to use? I have done some research today, here's my findings. 1. Test Results First, let's see some tests. I've tested 2 couples of the same method between WebUtility class and …


How to Redirect Old Domain URL to New Domain in IIS

When you are changing the domain name for your website, you are definitely going to solve the migration problem. You can not just stop DNS on your old domain, because this will cause your indexed pages being deleted by search engines. The correct way is to tell the search engine that you have a new domain name now, which is when the user access an old URL, redirect it to the new URL. Take my …


JQuery idTabs插件根据URL参数选择Tab

我们的项目用了SunSean的idTabs,但每个tab里的控件会触发postback,或者转到其他页面再转回来,这样当前选中的tab必丢。印度同事不肯用AJAX,无奈今天加班给印度人写个demo,通过回传URL参数来选择tab。 为了做这件事,除了jquery库和idTabs插件,我们还需要下载一个用来搞URL的插件:jquery.url.js,传送门:https://github.com/allmarkedup/jQuery-URL-Parser Tab菜单的HTML代码这样写,每个tab的div自己搞定,不发出来浪费页面了: <div class="tabmenu"> <ul> <li><a href="#idTab1">Dashboard</a></li> <li> …


ASP.NET中URL重写和Session冲突的问题

今天在改博客系统的一个Bug的时候,程序里用了Session,结果一跑就报错:只有在配置文件或 Page 指令中将 enableSessionState 设置为 true  时,才能使用会话状态。还请确保在应用程序配置的  \\ 节中包括  System.Web.SessionStateMod 或自定义会话状态模块。然而用VS自带的Web Server调试一点问题都没有。唯独在IIS下跑的时候老报错,错误语句就是那行用了Session的程序。唯一的区别就是VS下调试时,URL没有重写。于是我回到IIS上,用完整的URL试了下,果然木有问题。我所使用的是URLRewriter.dll,似乎是当年微软提供的,经过一番查找,似乎有很多人和我有同样的问题,不管他们用的是不是URLRewriter.dll。奇怪的是,并不是每个版本的IIS都会丢Session。我本机和网站服务器用的是IIS7, …