惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
V
V2EX
M
MIT News - Artificial intelligence
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
量子位
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
H
Help Net Security
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
爱范儿
爱范儿
雷峰网
雷峰网
博客园 - 叶小钗
宝玉的分享
宝玉的分享
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
D
DataBreaches.Net
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Proofpoint News Feed
T
Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
O
OpenAI News
Latest news
Latest news
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Attack and Defense Labs
Attack and Defense Labs
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Help Net Security
Help Net Security
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
N
Netflix TechBlog - Medium
L
LINUX DO - 最新话题
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
Scott Helme
Scott Helme

博客园 - sayo.net

website the breakpoint will not currently be hit. no symbols have been loaded for this document How to add MS Test to post build Resolve Error: The service cannot be activated because it does not support ASP.NET compatibility. Resolve Error: Service has zero application (non-infrastructure) endpoints. WCF Could not establish trust relationship for the SSL/TLS secure channel with authority Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Resolve error: Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’ 在IIS7.5上运行Message Security with UserName的WCF Service WCF部署问题两则 SQL Server Mangement Studio无法创建Database Dagrams的简单解决办法 一些有用的WCF相关链接 [Android开发]如何自定义ArrayAdapter 让Android的emulator支持web camera 如何旋转Android Emulator HTC Hero Android 2.1 真机调试 HTC Hero Android 2.1 真机调试 CouchDB系列 - 安装CouchDB Test from Windows Live Writer Silverlight Toolkit初探
在WCF中使用REST时,如何去掉URL中的.svc后缀
sayo.net · 2011-07-08 · via 博客园 - sayo.net

以Windows 7里面的IIS7.5为例。

假设我们的service method样子为

<WebGet(UriTemplate:="{parameter}")> _
        
<OperationContract()> _
        
Function ServiceMethod(ByVal parameter As StringAs Boolean

我们希望将一个这样的url

http://localhost/SomeService/ServiceMethod.svc/Parameter

使用

http://localhost/SomeService/ServiceProvider/Parameter

来访问

首先从这里安装一个URLRewrite。

 安装后打开IIS,从Features View里面可以看到URL Rewrite设置图标。

 

 双击进入设置,选择Add Rule(s)...然后选择Blank Rule

进行如下设置

Fill out the form with the following data (we will describe the patterns in detail in a moment):

  1. Name:                       RemoveSvcExtension (or any name you want)
  2. Requested URL:         Matches the pattern
  3. Using:                       Regular Expressions
  4. Pattern:                    ^([0-9a-zA-Z\-]+)/([0-9a-zA-Z\-\.\/\(\)]+)
  5. Ignore Case:             Checked
  6. Action Type:              Rewrite
  7. Rewrite URL:             {R:1}.svc/{R:2}
  8. Append QueryString   Checked
 

 稍微解释一下Regex Pattern的含义。

  • The "^" indicates the beginning of the line or string
  • The parenthesis "()" allow you to define a numbered capture group, meaning that you can reference everything inside the parens later by index.  In our example, we have 2 numbered capture groups 1 and 2.  You refer back to these later with the syntax: {R:1} and {R:2}
  • The pattern [0-9a-zA-Z\-]+ indicates any character in 0-9, lowercase a-z, uppercase A-Z or "-", one or more repetitions.
  • The / is a straight match to a slash "/".  In other words, the first named capture group will capture 0-9,a-z, A-Z and "-" prior to the first "/" and you will be able to reference them with {R:1}
  • Then we have another named capture group
  • The pattern [0-9a-zA-Z\-\.\/\(\)] matches any character in 0-9, lowercase a-z, uppercase A-Z or "-", ".", "/", "(", ")", one or more repetitions.