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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Elaine Shi

笔记《Hbase 权威指南》 读Java 804 - Quick refresher 804 pretest 解题 JAVA SE 803 考试前突击 Hadoop学习笔记之(二):实验Hadoop的文件块复制删除操作感受强大的容灾性 代码笔记:使用C#转移Wordpress博客到为知笔记或Evernote Hadoop准备篇之(一):Page Rank算法初探 Hadoop学习笔记(一):零Linux基础安装hadoop过程笔记 代码笔记:使用Xml2Linq和CodeDom自动重整多语化资源文件 WPF学习笔记(一):启程 网站推荐:这两年收藏的网站和链接 项目过程记录:记一次小小的与美方成功的离岸协作 读潘正磊访谈录 沤血分享之:使用Opera浏览器技巧全集 转一篇前端开发人员总结的《JavaScript 学习资源推荐》 网站推荐:一路收藏的正能量网站 如何实现单词拼写检查 (spellChecker) ? 由Suggestion衍生出来的算法学习 使用简单的反射技术重构组合查询串功能
WCF REST IIS6配置各种伤不起
Elaine Shi · 2013-05-11 · via 博客园 - Elaine Shi

一、IIS6,安装全部包括CGI,ASP,ASP.NET,ISAPI Flters, ISAPI Extension等

二、在IIS中添加一个SITE

1. 按如下图

e5a7bae4dfbf48b836ba741c5fe8ee07

2. 配置权限

f51e68e868c4e3d2fe40c81ffce3f841

46ee2137ed551110a7348b405b5f3cbf

4e4c90f390ca0fd42e57f27cc6f921ac

以上设置会出现以下带下划线的配置

<system.web>

    < compilation debug ="false " targetFramework ="4.0 ">

      < assemblies>

        < add assembly ="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

      </ assemblies>

    </ compilation>

    <!-- 没有这一段,会出现无权限错 -->

<authorization>

      < allow users ="* " />

    </ authorization>

    < authentication mode ="Forms " />

    < profile>

      < properties>

        <!-- todo:研究如何使用M$自带DLL来操作USER类 -->

        < add allowAnonymous ="false " defaultValue ="" name=" UserName" readOnly=" false" serializeAs=" String" type=" System.String" />

      </ properties>

    </ profile>

  </system.web>

fc87bdf35c03af69a04aff2a27ef26b9

3e04d26d281412870b0980b882b30619

如果没有上述MAPPING,则说明WCF没有安装到IIS中,需要运行

1. register ASP.NET runtime from VS.NET 2005/2008 command line run: aspnet_regiis –i –enable
2. map *.svc file by

2.1 Win2003 or XP run: "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r

2.2 Win2008 or Vista run: "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -L

(如果是64位,要选择64位的,反正我现在是这么选择的)

3. then restart your IIS  iisreset /noforce

注意appPool的设置须为integrated,否则会出现ISAPI and CGI Restriction的错误(不知道为什么我怎么安装都没这一项显示,WIN7环境?)

db04d45451bd3f0436fb4141fb0c18eb

三、各种TROUBLESHOOTING啊,

WCF ASP.NET (405) Method Not Allowed

请看这一段

http://social.msdn.microsoft.com/Forums/br/wcf/thread/31d3f1aa-28b6-4bd7-b031-73b7e7588e6d

Hi,
    Normally, 405 error code is because two reasons;
1) ASP.NET is not installed or register to your IIS
2) The *.svc file type is not mapped to the aspnet_isapi.dll
to solve problem:
1. register ASP.NET runtime from VS.NET 2005/2008 command line run: aspnet_regiis –i –enable

  %SystemRoot%\Microsoft.NET\Framework64\v4.0.30128\aspnet_regiis.exe -iru


2. map *.svc file by

2.1 Win2003 or XP run: "%WINDIR%\Microsoft     .Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r

(如果是64位,要选择64位的,反正我现在是这么选择的)

2.2 Win2008 or Vista run: "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -L

3. then restart your IIS  iisreset /noforce
Hope this helps,
-Jirapong

753d57d34c96573154db5531b94d8ab8

首先在

ASP.NET 4.0 无法加载 System.ServiceModel.Activation.HttpModule

"Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'"

This error can occur when IIS is installed after installing .NET Framework 4, or if the 3.0 version of the WCF Http Activation module is installed after installing IIS and .NET Framework 4.

To resolve this problem, you must use the ASP.NET IIS Registration Tool (Aspnet_regiis.exe,) to register the correct version of ASP.NET. This can be accomplished by using the –iru parameters when running aspnet_regiis.exe as follows:

aspnet_regiis.exe -iru

三、WCF在WEB.CONFIG中serviceModel节点的配置

5220ef5ea721693728a93dc1467d448f

使WCF能支持ASP SESSION等的配置:aspNetCompatibilityEnabled = "true "

<serviceHostingEnvironment multipleSiteBindingsEnabled=" true" aspNetCompatibilityEnabled ="true ">

只有加了webHttpBinding才能在网页中调用(比如ajax)

<endpoint address="" binding= "webHttpBinding"

这一条元数据交换是必备的

<endpoint address=" mex" binding=" mexHttpBinding" contract=" IMetadataExchange" />

endpoint也是要设置的,这个是指的wcf server host在IIS中的配置

<host>

   < baseAddresses>

      < add baseAddress ="http://localhost:8080/QuestionnaireService.svc " />

   </ baseAddresses>

</ host>

Behavior中定义了WCF服务的行为模式,比如需要禁用GET访问,则HttpGetEnabled = false

maxReceivedMessageSize 过小会使得接收的JSON串过大时出错

receiveTimeout 也需要改动为合适的值

直接RUN(DEBUG模式)WCF项目后,会自动触发wcfTestClient.exe工具,但改回到默认为webHttpBinding后,就木有了= 。- 要研究一下

C#

[ServiceBehavior(Name = "QuestionnaireService",

        InstanceContextMode = InstanceContextMode.PerSession,

        ConcurrencyMode = ConcurrencyMode.Single)]

public class QuestionnaireService : IQuestionnaireService

    {

        [ WebInvoke(UriTemplate="GetQuestionnaireData" )]

        [ ScriptMethod(UseHttpGet = false , ResponseFormat = ResponseFormat.Json)]

public string GetQuestionnaireData(string id)

        {

            serviceInit();

XMLQuestionnaire qn = new Questionnaire.Lib.Entities.Questionnaire ().Get(id.ToInt()).QuestionnaireDTO;

//清除不需要用在界面上的元素,减少RESPONSE大小

            qn.categories = null;

return qn.ToJSON();

        }

如果出现这个问题,AppPool没有设置成4.0

85c8ab466c6f9dbf0c0efc30e58acff7

如果这个菜单不出现

0f6c6e88895a66d24c65fd736c993105

那就再加一个WCF SERVICE进去