https://github.com/alexinea/dotnet-url-rewrite-examples
URL Rewrite Samples
https://github.com/alexinea/dotnet-url-rewrite-examples
rewrite
Last synced: about 1 month ago
JSON representation
URL Rewrite Samples
- Host: GitHub
- URL: https://github.com/alexinea/dotnet-url-rewrite-examples
- Owner: alexinea
- Created: 2017-03-21T01:19:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T08:06:41.000Z (about 9 years ago)
- Last Synced: 2025-12-31T00:35:52.842Z (5 months ago)
- Topics: rewrite
- Language: C#
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ASP.NET UrlWrite 样例
### 问题
现有 `pc` 和 `mobile` 两文件夹(其文件夹内的结构也不同),根据用户的设备类型自动选择显示 pc 版或 mobile 版。
> **推荐**:使用栅格化的自适应设计让页面自动适应不同设备,以避免本模块造成的性能损失。
***
### ASP.NET URL Rewrite
项目:`src\UrlWrite.AspNet`
**仅可用于 IIS 7+**
`web.config` 的改动:
在 `system.webServer:modules` 内增加配置:
```
```
在 `system.webServer:handlers` 内增加配置:
```
```
推荐阅读:
+ [Bikeman868/UrlRewrite.Net](https://github.com/Bikeman868/UrlRewrite.Net)
***
### ASP.NET Core URL Rewrite
项目:`src\UrlRewrite.AspNetCore`
NuGet 安装:
```
PM> install-package Wangkanai.Responsive -pre
```
在 `ConfigureServices` 方法中配置:
```
services.AddResponsive()
.AddViewSuffix()
.AddViewSubfolder();
```
在 `Configure` 方法中使用中间件:
```
app.UseResponsive();
```
`ASP.NET Core Responsive` 会根据你设备的种类调用不同的视图:
+ 如果使用的是 `AddViewSuffix()`,则路径形如 `views/[controller]/[action]/index.mobile.cshtml`
+ 如果使用的是 `AddViewSubfolder()`,则路径形如 `views/[controller]/[action]/mobile/index.cshtml`
推荐阅读:
+ [URL Rewriting Middleware in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting)
+ [ASP.NET Core Responsive](https://github.com/wangkanai/Responsive)