我已经创建了一个有效的WCF服务.我现在想为它添加一些安全性来过滤Ip地址.我已经按照示例中的microsoft发布样本来尝试添加IDispatchMessageInspector,它将引发调用AfterReceiveRequest,然后如果ip地址不是来自允许列表则抛出错误.
看完代码后; 他们使用'wsHttpBinding'配置它,但我想使用'webHttpBinding'或'basicHttpBinding'.但是当我设置它时,我得到错误:
'http://upload/api/Api.svc/soap'中的端点没有与None MessageVersion的绑定.'System.ServiceModel.Description.WebHttpBehavior'仅适用于WebHttpBinding或类似绑定.
我的配置是:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<!--Set up the service-->
<services>
<service behaviorConfiguration="SOAPRESTDemoBehavior" name="HmlApi">
<endpoint address="rest" binding="webHttpBinding" contract="VLSCore2.Interfaces.IHmlApi" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" />
<endpoint address="soap" binding="basicHttpBinding" contract="VLSCore2.Interfaces.IHmlApi" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" />
</service>
</services>
<!--Define the behaviours-->
<behaviors>
<serviceBehaviors>
<behavior name="SOAPRESTDemoBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<!---Endpoint -->
<endpointBehaviors>
<behavior name="SOAPRESTDemoEndpointBehavior">
<ipFilter/>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="ipFilter" type="VLSCore2.Api.IpFilterBehaviourExtensionElement, VLSCore2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
所以我想知道如何在不使用WebHttpBinding的情况下设置我的消息检查器.这甚至可能吗?
我想使用SOAP'basicHttpBinding'而不是wsHttpBinding(以及所有WS*)相关的开销....
我有一个表,其中的日期时间格式为:
2011-07-01 15:17:33.357
Run Code Online (Sandbox Code Playgroud)
当我在对象上执行.ToString()时,我正在接受ac#DateTime我将以格式获取DateTime:
04/07/2011 06:06:17
Run Code Online (Sandbox Code Playgroud)
我想知道我是如何正确传递正确的DateTime的,因为当我运行我们代码中的SQL时它不起作用(即选择正确的DateTime).我不能使用SQL分析器.
这是代码:
//looks to if a user has had any activity in within the last time specified
public bool IsUserActivitySinceSuppliedTime(int userId, DateTime since)
{
//get everything since the datetime specified [usually 5 hours as this is
//how long the session lasts for
string sql = "SELECT * FROM tbl_webLogging WHERE userid = @userid AND DateAdded > @sinceDateTime";
SqlParameter sinceDateTimeParam = new SqlParameter("@sinceDateTime", SqlDbType.DateTime);
sinceDateTimeParam.Value = since;
SqlCommand command = new SqlCommand(sql);
command.Parameters.AddWithValue("@userid", userId);
command.Parameters.Add(sinceDateTimeParam); …Run Code Online (Sandbox Code Playgroud) 我试图使用以下代码:
private Nullable<List<IpAddressRange>> ipAddressRangeToBind;
Run Code Online (Sandbox Code Playgroud)
但我收到以下警告:
类型List必须是非可空值类型,以便在泛型类型或方法'System.Nullable'中将其用作参数'T'.
我有一个布局页面和一些使用它的页面.但我想在一些使用它的子页面上实现导航控件.所以我想使用另一个嵌套布局页面.这可能吗?
我有一个巨大的恼人的问题,我有一个观点:
@{
if(ViewBag.Section == "Home")
{
<div id="headerfrontPage">
}
else
{
<div id="header">
}
}
Run Code Online (Sandbox Code Playgroud)
我收到编译错误:
代码块缺少结束"}"字符.确保此块中的所有"{"字符都有匹配的"}"字符,并且没有任何"}"字符被解释为标记.
我如何有条件地写一个div?它的基础是hack ...
可以在网站上使用PNG图像吗?我没有真正看到他们使用太多,所以想知道缺点是什么.必须有一些肯定每个人都会使用它们吗?...
例如,它们是否符合MSIE和Chrome标准......
我可以获得以下任一xml:
<?xml version="1.0" encoding="UTF-8"?>
<dc:video xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>
A vid with Pete
</dc:title>
<dc:description>
Petes vid
</dc:description>
<dc:contributor>
Pete
</dc:contributor>
<dc:subject>
Cat 2
</dc:subject>
</dc:video>
Run Code Online (Sandbox Code Playgroud)
要么:
<?xml version="1.0" encoding="UTF-8"?>
<video>
<title>
A vid with Pete
<title>
<description>
Petes vid
<description>
<contributor>
Pete
<contributor>
<subject>
Cat 2
<subject>
</video>
Run Code Online (Sandbox Code Playgroud)
我试图访问一个元素:
string title = xmlDocFromOneLan.SelectSingleNode(@"/video/title").InnerXml;
Run Code Online (Sandbox Code Playgroud)
但是对于xml文档1,它由于命名空间而无法工作.
c#中有没有办法使用xpath忽略命名空间?我只是想选择我真的不关心命名空间的节点.(命名空间可以是DC DN或DCN等).
"/视频"
会读到:
<video></video>
or
<dc:video></video>
or
<dcn:video></video>
Run Code Online (Sandbox Code Playgroud) 只是想知道管道在这意味着什么?我以前从未见过它:
FileSystemAccessRule fullPermissions = new FileSystemAccessRule(
"Network Service",
FileSystemRights.FullControl | FileSystemRights.Modify,
AccessControlType.Allow);
Run Code Online (Sandbox Code Playgroud)
干杯
我写了一个服务,它有一个.svc文件.我可以浏览这项服务,但这似乎是一种奇怪的方式.我想知道是否可以使用.svc文件生成服务,或者我们是否应该考虑使用WCF服务主机并设置绑定等....
如果我开始将脚本标记定义为ECMA会发生什么?它会执行不同的标准吗?
有没有人真正使用ECMA脚本而不是直接Javascript ...?