Edi Wang

.NET and Azure Developer

Server and Tools Server, Software Tips and Tricks

Install Linux Subsystem on Windows 10 Fall Creators Update

In the recent Windows 10 v1709 Fall Creators Update, the Windows subsystem for Linux has been improved a lot. Let's see how easy it is now to install Linux on Windows. 1. Enable Windows Subsystem for Linux Because the classic control panel has been hidden, now the quickest way to access Programs and Features is to run appwiz.cpl And then check "Windows Subsystem for Linux" under "Turn Windows …

Windows Linux

How to Redirect Old Domain URL to New Domain in IIS

When you change the domain name for your website, you are definitely going to solve the migration problem. You cannot just stop DNS on your old domain, because this will cause your indexed pages to be 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 accesses an old URL, redirect it to the new URL. Take my blog …

IIS URL URL Rewrite

How to Manage Azure App Service in IIS Manager (inetmgr)

The website we created on Azure seems can be only managed in the web portal or in the Server Explorer of Visual Studio. If we would like to use IIS to manage more powerful scenarios, seems VM is the only way. But that's not true. First, the IIS comes with Windows 8.1 can't connect to Azure by default. We need to install an extension http://www.iis.net/downloads/microsoft/iis-manager After install. …

IIS Azure

Azure Website Showing 404 for .woff Fonts in IE

If you are using Website on Microsoft Azure (Currently renamed to Web Apps), you will find the .woff web font is not working in IE, it returns 404. Based on my experience, this is because IIS is not configured to use the correct MimeType. However, we can not operate the IIS on Azure, there's no RDP into an Azure Web Apps backend machine. How can we do that? In fact, after IIS7, the MineType is …

IIS Azure

Get Clear Password from IIS App Pool

Sometimes, in order to get necessary permissions, we will assign domian accounts or local accounts for IIS app pool. For example, it usually happens for SharePoint deployment. However, this is not a secure way, because the password for these accounts are saved in clear text. For local accounts, the password is not readable. But if you are using domain accounts. The IIS Admin can read your …

IIS Security

Run Scheduled Tasks in ASP.NET Application

在ASP.NET里运行定时任务,这是个老生常谈的话题了,撇开那些用per request搞定屌丝办法,目前最好的解决办法只有2种: 1. 如果你有大微软的Azure,可以直接在网站服务中找到Jobs,自己看一下就会了 2. 如果你是屌丝,买不起Azure,就用本文介绍的WebBackgrounder搞 由于ASP.NET是服务器端Web框架,所以一般而言,一个操作的往往是只有收到客户端Request之后才能执行的,如果网站一直没人访问,没有Request进来,如何执行代码呢?定时任务就是这种坑爹场景。 还好,大微软的MVC帝、ASP.NET小王子haacked蜀黍给我们写了个 http://www.nuget.org/packages/WebBackgrounder/ 专门捣鼓这种场景。作为一个屌丝程序猿,和大牛的区别就在于“好编程,不求甚解”。所以我们不必在意它是怎么实现的,只要会用就行 …

ASP.NET Jobs

简单粗暴有效解释ASP.NET中的线程池是怎样处理Http请求的

自从有了.NET 4.5,我们又多了一个装逼语法:async,await。但如果错用就会装逼不成反变傻逼。首先我们得明白在ASP.NET中async await所针对的问题,这样才能正确的装逼。于是我们就不得不先研究一下线程池。 在IIS服务器上,处理Http请求的是线程,和Windows的其他软件一样,干活的永远是线程,而不应该说是进程。一个线程同时只能处理一个request,而web上的request不可能同时永远只有一个,所以线程需要和他的小伙伴们一起组成线程池,才能保证网站的响应。当一个线程处理完了手头的请求,它就被释放掉了,于是如果再有新的请求进来他就能再去处理。但如果当线程用完了,并且他们正在处理的请求都没完成,网站就卡住了,用户就只能等出翔。这时候IIS就会返回一个HTTP 503爆给用户。 打个比方,IIS服务器就好像银行,Http请求就好像顾客,银行开的窗口数量就是进程池 …

IIS Async Async Await Thread

针对IIS7以上的ASP.NET网站自定义错误页面与异常日志总结

自定义错误页面和异常记录是个很古老的话题了,但依旧可以让人爆到现在。在我做了无数次试验并总结经验和原则后,写下本文,已警后人。 本文的范围和限制 本文仅仅适用于部署在IIS7或以上版本中的ASP.NET 4.0集成模式应用程序。IIS7以上的意思是Windows Server 2008以上服务器适用。我已在WS2012R2,IIS8上测过。 本文的方法均适用于ASP.NET WebForm和MVC应用程序。 本文针对的问题 静态错误页面好还是动态错误页面好?我该如何设计ASP.NET网站错误处理? 我不希望错误页面后面跟上aspxerrorpath=…这个小尾巴。 我的自定义错误页面在VS里调试是好的,为什么部署到服务器上就出不来了? 我的自定义错误页面可以正常显示,但为什么返回的Http状态码不正确? 异常日志该怎样记录,有没有比较好的实践? 一、错误页面的选择 选择静态html页面 …

IIS

在IIS服务器上安装和配置Web Deploy (WS2008R2)

作为ASP.NET开发者,部署应用到测试或生产环境是家常便饭。不知道大家平时都是怎么部署网站的?手工拷贝文件?FTP?还是高端的package解压?对我来说,最方便的还是WebDeploy,它可以让我从Visual Studio中一键部署网站到IIS服务器,并且智能判断哪些文件是新增的,哪些是需要修改或删除的。Windows Azure Website就默认支持这样的部署方式。但我们不可能一直在公有云上做开发,如果我们想把这样方便的功能带到本地怎么办呢? 经过开荒,我在Windows Server 2008 R2和Windows Server 2012 R2上都成功配置了Web Deploy。目前用的最多的还是WS2008R2,所以我就带大家来看看如何在这款系统上安装和配置Web Deploy。 首先,你需要在IIS上安装管理服务。 在Server Manager(服务器管理)里面,展开 …

IIS

如何在Windows Azure虚拟机上配置外网能访问的FTP服务器

昨天哥被功夫网墙出了翔,一怒之下打算用Windows Azure VM建个FTP来下东西,本来以为只要配置IIS和防火墙再打开Azure Portal的21端口就行的,结果又被Windows Azure爆出了翔(Blow up to shit)。在Azure上配置FTP没那么容易的。 首先,如何安装和正常配置一个FTP我不叙述了,大家可以自己搞定。Azure唯一特殊的就在于开防火墙端口。 1. 你需要知道你VM的外网IP,可以用ping命令,虽然Azure VM不允许被ping,但解析IP还是没问题的。 2. 将IP添加到FTP站点的FTP Firewall Support里面。 3. 由于Data Channel Port是在IIS Root Node上被锁住的,所以还要回IIS Root去配端口范围。这些端口是FTP用来传输数据的(FTP居然不是只用21端口的,虽然不知道是为什么 …

IIS VM FTP