[★] VS Code 插件开发

Add Headers for Static Files with ASP.NET Core

Sometimes we need to add some headers for static file requests.

For example, if we want to allow third-party website to access images or audios through XHR (it’s usefull when you want to do some custom decoding with these files). You need to add Access-Control-Allow-Origin: * (relpace * with your domain if you don’t realy want to allow any domain to access).

阅读原文>>

CSS Style inherit

Take a look at this

h1{
    color: red;
}

.content h1{
    color: green;
}

.content .header h1 {
    color: blue;
}

.content .header{
    color: purple;
}
.content .header h1 {
    color: inherit;
}

The h1 will take the color purple instead of green.

The inherit CSS-value causes the element for which it is specified to take the computed value of the property from its parent element. It is allowed on every CSS property.

That’s it.

阅读原文>>

Run dotnet core on Azure.cn

.net core RTM 了,Azure global 已经提供支持,但是慢半拍的 Azure 中国 WebSites 目前并不支持 asp.net core。

Orz

经过各种尝试,终于发现了临时解决的办法:

让我们把整个 .net core 上传上去把

操作步骤

  • 将系统安装的.net core 文件夹上传到 wwwroot 的父级目录, 让我们能够在 wwwroot 使用 ..\dotnet\dotnet.exe 访问到它。
  • 修改发布后的 web.configconfiguration\system.webServer\aspNetCore@processPath%LAUNCHER_PATH%dotnet 改为 ..\dotnet\dotnet.exe

:)

有一个问题是,Visual Studio 发布项目后,会自动把 processPath 改为 dotnet,避免每次上传手动修改,我们在 project.json 中添加一个后处理脚本

  // project.json
  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%",
      "node azurecn.js %publish:OutputPath%" // <====== 执行 node 脚本,替换processPath
    ]
  }
  
  // azurecn.js
  var fs = require('fs');
  var path = require('path');
  var folder = process.argv[2];
  var filePath = path.join(folder, 'web.config');
  console.log(filePath);
  var content = fs.readFileSync(filePath, 'utf-8');
  if (content.indexOf('processPath="dotnet"') > 0) {
      content = content.replace('processPath="dotnet"', 'processPath="..\dotnet\dotnet.exe"');
      fs.writeFileSync(filePath, content);
  }
  

整个世界都美好了!(●’◡’●)

阅读原文>>

Hi from new host

今天换了新域名 imzc.me

作为一个新的开始,好好写文章!

阅读原文>>