小编Ada*_*dam的帖子

WCF .net 4.0 HTTP基本身份验证

我现在已经为此吵了几天了.

我只是尝试使用基本HTTP身份验证将用户名/密码传递到我的RESTful服务中.其他一切都很棒!

这是我的web.config看起来像:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>

  <system.serviceModel>

    <bindings>
      <wsHttpBinding>
        <binding name="">
          <security mode="Message">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceCredentials>
            <userNameAuthentication …
Run Code Online (Sandbox Code Playgroud)

c# asp.net rest wcf restful-authentication

5
推荐指数
1
解决办法
9277
查看次数

UriTemplate WCF

有没有一种简单的方法可以在同一个定义中使用多个UriTemplates.

 [WebGet(UriTemplate = "{id}")]
Run Code Online (Sandbox Code Playgroud)

例如,我想要/ API/{id}和/ API/{id} /来调用相同的东西.如果有/最后,我不希望它重要.

c# rest wcf

5
推荐指数
1
解决办法
7975
查看次数

在IIS 7中重定向网站的最佳方法

确保在IIS 7中托管的网站上的所有页面都使用www重定向的最佳方法是什么?子域...以下示例:

http://site.com ==> http://www.site.com
Run Code Online (Sandbox Code Playgroud)

要么

http://site.com/somepage.html ==> http://www.site.com/somepage.html
Run Code Online (Sandbox Code Playgroud)

iis iis-7 url-rewriting url-routing iis-7.5

4
推荐指数
1
解决办法
4751
查看次数

使用System.Threading使用50%CPU的简单.exe

我有一个非常简单的可执行文件,大约每3秒检查一个特定的文件夹,看看那里是否有文件.如果它找到一个文件,它会做一些事情,然后返回每3秒检查一次文件夹.

有人报告说这个可执行文件有时占用了50%的CPU,有没有关于如何正确执行此操作的建议.下面是我如何做这个的示例代码.

// Check our folder every x seconds
Timer = new System.Threading.Timer(TimerCallback, null, 0, Global.SecondsToCheckPrintFolder * 1000);
Run Code Online (Sandbox Code Playgroud)

.net c# desktop-application

3
推荐指数
1
解决办法
496
查看次数

验证Facebook用户ID和访问令牌服务器端

我在我的网站上使用Facebook Javascript SDK来验证用户身份.所以我得到了他们的ID和他们的访问令牌.在后端,我想验证此信息并确保令牌仍然有效.

在c#中最简单的方法是什么?

c# facebook c#-4.0

3
推荐指数
1
解决办法
1809
查看次数

删除尾随斜杠 - 不使用IIS重写ASP.net

如何在不使用IIS重写模块的情况下删除尾部斜杠?

我假设我可以在global.asax.cs文件中添加一些RegisterRoutes函数?

c# asp.net routes

2
推荐指数
1
解决办法
3008
查看次数

使用策略将 AWS IOT 设备限制为自身

希望根据设备用于身份验证的证书将设备限制为 AWS IOT 内部的资源(影子)。

Device1 附加到 Cert1 - 我想要一个通用策略,只允许 Device1 更新设备 1 的影子,而不更新设备 2 的影子

但所有这些都是由设备用来进行身份验证的证书触发的。

以下政策似乎不起作用 - 有什么帮助吗?

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:Connect",
      "Resource": "*",
      "Condition": {
        "Bool": {
          "iot:Connection.Thing.IsAttached": [
            "true"
          ]
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": [
        "iot:Publish",
        "iot:Receive"
      ],
      "Resource": [
        "arn:aws:iot:us-east-1:xxxxxx:topic/${iot:Connection.Thing.ThingTypeName}/${iot:Connection.Thing.ThingName}",
        "arn:aws:iot:us-east-1:xxxxxx:topic/${iot:Connection.Thing.ThingTypeName}/${iot:Connection.Thing.ThingName}/*"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "iot:Subscribe"
      ],
      "Resource": [
        "arn:aws:iot:us-east-1:xxxxxx:topicfilter/${iot:Connection.Thing.ThingTypeName}/${iot:Connection.Thing.ThingName}",
        "arn:aws:iot:us-east-1:xxxxxx:topicfilter/${iot:Connection.Thing.ThingTypeName}/${iot:Connection.Thing.ThingName}/*"
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

aws-iot

1
推荐指数
1
解决办法
662
查看次数