似乎使用WCF的本机DataContractJsonSerializer或ASP.NET的本机JavaScript序列化程序无法将Entity Framework对象序列化为JSON.这是由于序列化器拒绝的引用计数问题.我也尝试过Json.NET,它也没有专门针对引用计数问题.
编辑: Json.NET现在可以序列化和反序列化实体框架实体.
我的对象是实体框架对象,它们被重载以执行其他业务功能(例如,身份验证等),我不想用平台特定的属性等来装饰这些类,因为我想呈现一个与平台无关的API .
我实际上曾在https://blog.programx.co.uk/2009/03/18/wcf-json-serialization-woes-and-a-solution/上写过关于我所经历的各个步骤的博客.
我错过了一些明显的事吗?
我正在编写各种ASP.NET Server控件,我需要删除默认情况下包装我的控件的标记.我知道您可以将标记更改为其他标记(如此问题,如何更改自定义控件的渲染行为是否为跨度)但是如何防止它?
我继承自WebControl(也可以从CompositeControl继承).
我通常得到:
<span>Control output</span>
Run Code Online (Sandbox Code Playgroud)
我需要:
Control output
Run Code Online (Sandbox Code Playgroud)
我重写了RenderContents(HtmlTextWriter输出)和CreateChildControls()方法(跨越各种控件).我迫切需要使用RenderContents(HtmlTextWriter输出)方法来解决这个问题.
我在VS2008中构建解决方案时遇到问题.通常,它在环境中编译良好.有时,它失败了:
/xxx_WEB/secure/CMSManagedTargetPage.aspx(1): error ASPPARSE: Circular
file references are not allowed.
Run Code Online (Sandbox Code Playgroud)
我重建,它工作正常.
然而,现在,我正在设置CruiseControl.NET系统,并在将构建集成到CC之前使用MSBuild测试我检出的代码.现在,每次我MSBuild,我得到:
"Q:\cc\xxx\checked out from svn\xxx.sln" (default target) (1) ->
(xxx_WEB target) ->
/xxx_WEB/secure/CMSManagedTargetPage.aspx(1): error ASPPARSE: Circular
file references are not allowed.
Run Code Online (Sandbox Code Playgroud)
问题是,我看不出这个引用的位置.
我已经在整个解决方案中搜索了引用,并且除了在页面或其代码隐藏之外的任何地方或者在字符串中,都没有引用页面本身(CMSManagedTargetPage),例如:
C:\ dev2008\xxx\IWW.xxx.ASPNET\AspxHttpHandler.cs(82):inputFile = context.Server.MapPath("〜/ secure/CMSManagedTargetPage.aspx"); C:\ dev2008\xxx\IWW.xxx.ASPNET\AspxHttpHandler.cs(83):virtualPath ="〜/ secure/CMSManagedTargetPage.aspx";
我的汇编参考也很好(据我所知).我的Web应用程序位于依赖项的"顶部",没有任何引用它,因此错误页面因此不能导致循环引用.当然,页面本身可能会在同一个程序集/网站中引用诸如UserControl之类的内容,但如前所述,对CMSManagedTargetPage的搜索没有产生任何结果,因此不会发生这种情况.
更改web.config中的批处理属性对MSBuild没有影响.
我觉得奇怪的是它"有时"在VS中失败并且总是在MSBuild中失败.我错过了一些微妙之处吗?
我已经使用IIS 7.5将MVC 4网站部署到Windows 2008 R2服务器..NET 4.5安装在服务器上.
该网站在本地工作正常.所有路由工作正常.但是,当我把它放在服务器上时,没有任何作用.我已经确认DNS /绑定工作是通过在站点中放置一个静态文本文件,这是有效的.
这是我尝试过的一些事情:
我试过/确认过:
我错过了什么吗?我的下一个绝望行为是安装完整的ASP.NET MVC 4堆栈,包括Visual Studio Express,SQL Express等,以确定它是否有效.我真的不想做.这是一个生产服务器!
更新: 我应该在登台服务器上添加相同的站点在内部的等效配置上工作.
我有一个异步"上游"的方法.我正在尝试遵循最佳实践并在堆栈中一直进行qith异步.
在MVC中的Controller操作中,我可以预见到遇到死锁问题.如果我依赖.Result().
将Controller操作更改为异步似乎是要走的路,但问题是在lambda中多次调用async方法.
我如何等待返回多个结果的lamda ?
public async Task<JsonResult> GetLotsOfStuff()
{
IEnumerable<ThingDetail> things= previouslyInitialisedCollection
.Select(async q => await GetDetailAboutTheThing(q.Id)));
return Json(result, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
您可以看到我尝试使lambda异步,但这只是一个编译器异常:
无法转换源类型
System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<ThingDetail>目标类型System.Collections.Generic.IEnumerable<ThingDetail>
我在哪里错了?
当WCF配置得很好并且jQuery很好地构建其请求/理解响应时,我正在努力获得"神奇"的时刻.
我有一个服务:
<%@ ServiceHost Language="C#" Debug="true" Service="xxx.yyy.WCF.Data.ClientBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Run Code Online (Sandbox Code Playgroud)
这是由Rick Strahl建议的,以避免在Web.config中定义行为.
我的WCF服务接口位于另一个程序集中:
namespace xxx.yyy.WCF.Data
{
[ServiceContract(Namespace = "yyyWCF")]
public interface IClientBroker
{
[OperationContract]
[WebInvoke(Method="POST",BodyStyle=WebMessageBodyStyle.Wrapped,ResponseFormat=WebMessageFormat.Json)]
IClient GetClientJson(int clientId);
}
}
Run Code Online (Sandbox Code Playgroud)
具体的服务类是:
namespace xxx.yyy.WCF.Data
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
class ClientBroker : IClientBroker
{
public IClient GetClientJson(int clientId)
{
IClient client=new Client();
// gets and returns an IClient
return client;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的IClient是一个Entity Framework类,因此适当地使用DataContract/DataMember属性进行修饰.
我试图使用Rick Strahl的博客http://www.west-wind.com/weblog/posts/324917.aspx("全脂版")上列出的方法调用我的WCF服务.调试器很好地跳转到WCF服务(所以我的jQuery/JSON正在被理解)并获取IClient并返回它.但是,当我返回响应时,我会遇到各种无用的错误.我得到的错误并不重要.
我正在使用POST.
我是否正确使用接口而不是具体对象?因为它确实进入了WCF服务,它似乎是失败的结果的编码.
有没有人有任何想法?
在向同事展示昨天如何使用SVN时,我们在现有的Visual Studio解决方案中创建了一个测试文件夹和文件.我们将其称为"Test"文件夹,其中包含两个文件"Test.ascx"和"Test.ascx.cs".我们添加了它(或者Visual SVN添加了它,'因为它很棒)并且提交了它.我们还在项目的其他位置添加并提交了其他文件.
我们可以在存储库(和其他文件)中看到它.
在我自己的机器上进行更新以下拉这些新文件导致其他文件被正确拉下,但是没有出现Test文件夹.无论我多少次尝试从VS和TortoiseSVN(urgh)Repo浏览器中的各个点进行更新,它都无法看到有任何更改需要下拉.
我哪里错了?
我正在尝试将ServiceStack实现到我的MVC3项目中,并遵循以下教程:http://www.servicestack.net/ServiceStack.Hello/
我的Global.asax.cs现在看起来像:
public class MvcApplication : System.Web.HttpApplication
{
public class Hello
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
public class HelloService : IService<Hello>
{
public object Execute(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
public class HelloAppHost : AppHostBase
{
//Tell Service Stack the name of your application and where to find your web services …Run Code Online (Sandbox Code Playgroud) 我有一个WCF服务:
<%@ ServiceHost Language="C#" Debug="true" Service="IWW.MIGTurbo2.WCF.Security.SecurityBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Run Code Online (Sandbox Code Playgroud)
这可以使用我的web项目中的webHttpBinding正常工作.
我也希望这个服务可以被WinForms客户端使用,所以添加了一个basicHttpBinding绑定.
我的服务器配置文件目前是:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webScriptEnablingBehavior">
<enableWebScript />
</behavior>
<behavior name="webHttpEnablingBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpEnablingBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="webScriptEnablingBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="IWW.MIGTurbo2.WCF.Security.SecurityBroker" behaviorConfiguration="webHttpEnablingBehaviour">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<!-- This works for web-clients -->
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="default"
contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
<!-- This is for WinForms clients, but isn't working -->
<endpoint address="" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Windows Phone 7模拟器对Huddle API进行身份验证.但是,我没有取得任何成功.我一直得到"远程服务器返回错误:NotFound".我甚至试图"减少"我的代码,只是尝试一个直接的网站,例如.谷歌但仍然得到相同的结果.
我有以下代码:
string url = "http://www.google.com";
HttpWebRequest client= WebRequest.CreateHttp(new Uri(url)) as HttpWebRequest;
client.AllowReadStreamBuffering = true;
// Call and handle the response.
client.BeginGetResponse(
(asResult) =>
{
Dispatcher.BeginInvoke(
() =>
{
try
{
var response = client.EndGetResponse(asResult);
System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
string responseString = reader.ReadToEnd();
}
catch (WebException failure)
{
throw failure;
}
});
},
null
);
Run Code Online (Sandbox Code Playgroud)
执行总是在catch部分结束.但是,看过Fiddler2后,google.com似乎没有任何流量.所以似乎没有提出要求.
我在这里看到类似的问题使用WebClient/HttpWebRequest - WP7从https检索XML,但我使用的是标准端口,所以不确定这是否相关.我也尝试按照帖子简化代码,但没有成功.
有趣的是,最可能的选择似乎是因为我可能没有根据HttpWebRequest Breaks On WP7在我的AppManifestWM.xaml文件中定义网络功能,但我的AppManifestWM.xaml文件似乎已定义:
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
<App xmlns="" ProductID="{ac5b5d62-573c-4134-b290-0ad4f678ad7f}" Title="xxx.WindowsPhone7.Client" RuntimeType="Silverlight" Version="1.0.0.0" …Run Code Online (Sandbox Code Playgroud) c# ×3
wcf ×3
asp.net-mvc ×2
json ×2
.net-3.5 ×1
asp.net ×1
asp.net-ajax ×1
asynchronous ×1
iis-7.5 ×1
jquery ×1
lambda ×1
linq ×1
msbuild ×1
servicestack ×1
svn ×1
tortoisesvn ×1
visualsvn ×1