我想使用ASP.NET Web API 构建RESTful Web服务,第三方开发人员将使用它来访问我的应用程序的数据.
我已经阅读了很多关于OAuth的内容,它似乎是标准的,但找到一个很好的样本,文档解释它是如何工作的(实际上确实有效!)似乎非常困难(特别是对于OAuth的新手).
是否有实际构建和工作的示例,并说明如何实现它?
我已经下载了很多样本:
我还看过一些博客,建议一个简单的基于令牌的方案(像这样) - 这似乎重新发明了轮子,但它确实具有概念上相当简单的优势.
似乎在SO上有很多这样的问题,但没有好的答案.
每个人在这个领域做什么?
有没有什么办法可以指定标准或自定义数字格式字符串来始终输出符号,无论是+ ve还是-ve(尽管它应该为零做什么,我不确定!)
我正在尝试使用我的WPF应用程序中的FolderBrowserDialog - 没什么特别的.我不太关心它有Windows窗体的外观.
但是,当我调用ShowDialog时,我想传递一个IWin32Window的所有者窗口.如何从我的WPF控件中获取此信息?
实际上,这有关系吗?如果我运行此代码并使用没有参数的ShowDialog重载,它可以正常工作.在什么情况下我需要通过所有者窗口?
谢谢,
克雷格
我一直在关注米格尔·卡斯特罗对WCF优秀文章在这里,这一切都工作很好,但我有以下代码
public AdminClient()
{
ChannelFactory<IProductAdmin> factory = new ChannelFactory<IProductAdmin>();
productAdminChannel = factory.CreateChannel();
}
Run Code Online (Sandbox Code Playgroud)
在我的app.config文件中,我有以下配置:
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost:8002/ProductBrowser"
binding="netTcpBinding"
contract="Contracts.IProductAdmin" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行AdminClient的构造函数时,我得到一个异常,说明端点没有定义.但是,如果我更改配置以给端点命名,然后按如下方式创建工厂,则它可以工作.
public AdminClient()
{
var fac = new ChannelFactory<IProductAdmin>("admin");
productAdminChannel = fac.CreateChannel();
}
Run Code Online (Sandbox Code Playgroud)
<system.serviceModel>
<client>
<endpoint name="admin"
address="net.tcp://localhost:8002/ProductBrowser"
binding="netTcpBinding"
contract="Contracts.IProductAdmin" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我喜欢这个的解释.MSDN中的文档没有太大帮助......
我有一个ListBox控件,我在网格布局中呈现固定数量的ListBoxItem对象.所以我将ItemsPanelTemplate设置为Grid.
我从后面的代码访问Grid以配置RowDefinitions和ColumnDefinitions.
到目前为止,它都像我期望的那样工作.我有一些自定义的IValueConverter实现,用于返回每个ListBoxItem应该出现的Grid.Row和Grid.Column.
但是我有时会遇到奇怪的绑定错误,我无法弄清楚它们为什么会发生,或者即使它们在我的代码中.
这是我得到的错误:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ListBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
谁能解释一下发生了什么?
哦,这是我的XAML:
<UserControl.Resources>
<!-- Value Converters -->
<v:GridRowConverter x:Key="GridRowConverter" />
<v:GridColumnConverter x:Key="GridColumnConverter" />
<v:DevicePositionConverter x:Key="DevicePositionConverter" />
<v:DeviceBackgroundConverter x:Key="DeviceBackgroundConverter" />
<Style x:Key="DeviceContainerStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Grid.Row" Value="{Binding Path=DeviceId, Converter={StaticResource GridRowConverter}}" />
<Setter Property="Grid.Column" Value="{Binding Path=DeviceId, Converter={StaticResource GridColumnConverter}}" />
<Setter Property="Template"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试将WCF服务部署到我的服务器,托管在IIS中.当然它适用于我的机器:)
但是当我部署它时,我收到以下错误:
此集合已包含方案http的地址.此集合中每个方案最多只能有一个地址.
谷歌搜索,我发现我必须将一个serviceHostingEnvironment元素放入web.config文件:
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Run Code Online (Sandbox Code Playgroud)
但是一旦我这样做了,我得到以下内容:
无法通过绑定BasicHttpBinding找到与端点的scheme http匹配的基址.注册的基地址方案是[https].
它似乎不知道基地址是什么,但我该如何指定呢?这是我的web.config文件的相关部分:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfPortal"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
openTimeout="00:10:00" closeTimeout="00:10:00">
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal"
bindingConfiguration="BasicHttpBinding_IWcfPortal">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
任何人都可以了解正在发生的事情以及如何解决这个问题?
我在VS2008中构建了一个Web安装项目,它将我的ASP.NET/Silverlight应用程序安装到IIS中.这在除Windows Server 2008之外的任何地方都可以正常工作
我在MSI安装程序日志文件中收到此错误消息:
MSI (c) (C8:D8) [15:02:21:067]: Invoking remote custom action. DLL: C:\Users\ADMINI~1\AppData\Local\Temp\1\MSIB7DD.tmp, Entrypoint: SetTARGETSITE
MSI (c) (C8!F0) [15:02:21:097]: Creating MSIHANDLE (14) of type 790531 for thread 2288
INFO : [08/27/2009 15:02:21:097] [SetTARGETSITE ]: Custom Action is starting...
INFO : [08/27/2009 15:02:21:107] [SetTARGETSITE ]: CoInitializeEx - COM initialization Apartment Threaded...
ERROR : [08/27/2009 15:02:21:107] [SetTARGETSITE ]: FAILED: -2147221164
ERROR : [08/27/2009 15:02:21:127] [SetTARGETSITE ]: Custom Action failed with code: '340'
INFO : [08/27/2009 15:02:21:137] [SetTARGETSITE ]: Custom Action completed …Run Code Online (Sandbox Code Playgroud) 我刚刚将一个项目从VS2008升级到了VS2010,但我仍然以3.5框架为目标.
在我的项目文件中,我有一个自定义任务来运行SGEN来生成我的XmlSerializers.dll.但是,正在运行的sgen版本的目标是4.0框架.因此,当我运行我的应用程序时,我收到错误消息:
"无法加载文件或程序集'XXXX.XXXX.XmlSerializers'或其依赖项之一.此程序集由比当前加载的运行时更新的运行时构建,无法加载."
Sgen任务看起来像这样:
<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)">
<!-- Delete the file because I can't figure out how to force the SGen task. -->
<Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
<SGen BuildAssemblyName="$(TargetFileName)" BuildAssemblyPath="$(OutputPath)" References="@(ReferencePath)" ShouldGenerateSerializer="true" UseProxyTypes="false" KeyContainer="$(KeyContainerName)" KeyFile="$(KeyOriginatorFile)" DelaySign="$(DelaySign)" ToolPath="$(SGenToolPath)">
<Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" />
</SGen>
</Target>
Run Code Online (Sandbox Code Playgroud)
有ToolPath ="$(SGenToolPath)".如何让它运行目标为3.5的版本?
这里有一个类似的问题,但它对我没什么帮助.
我正在尝试在Silverlight应用程序中使用第三方组件,当我尝试创建控件的实例时,我得到一个XamlParseException:
{System.Windows.Markup.XamlParseException: **Set property 'System.Windows.FrameworkElement.Style' threw an exception.** [Line: 0 Position: 0]
---> System.Windows.Markup.XamlParseException: **Elements in the same ResourceDictionary cannot have the same x:Key** [Line: 1739 Position: 47]
at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)
--- End of inner exception stack trace ---
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at SpellCheckerSample.StandardSpellDialog.InitializeComponent()
at SpellCheckerSample.StandardSpellDialog..ctor()}
Run Code Online (Sandbox Code Playgroud)
我该怎么调试呢?我如何知道位置47所在的文件行1739?
我有一个ScrollViewer,其中包含一个包含多个控件的Grid.用户可以通过控件进行制表,但最终它们会切换到不在视图中的控件 - 因此他们必须进行手动滚动以使控件再次可见.
有没有办法让ScrollViewer自动滚动,以便始终可以看到聚焦控件.如果失败了,有没有什么方法可以让这个工作,除了在每个控件上听一个GotFocus事件,然后滚动ScrollViewer使控件可见?
目前我正在使用Silverlight 2.
.net ×2
c# ×2
silverlight ×2
wcf ×2
wpf ×2
asp.net-mvc ×1
data-binding ×1
formatting ×1
iis ×1
installer ×1
listbox ×1
oauth ×1
scrollviewer ×1
sgen ×1
winapi ×1
xaml ×1