小编Sex*_*yMF的帖子

什么是HTML中的CDATA?

在JavaScript标记和HTML中使用CDATA有什么用?

<script type="text/javascript"> 
// <![CDATA[

// ]]>
</script> 
Run Code Online (Sandbox Code Playgroud)

html javascript xhtml cdata

165
推荐指数
6
解决办法
15万
查看次数

在mongodb中运行javascript脚本(.js文件),包括js中的另一个文件

我想编写一个用于插入和更新mongodb数据的长脚本.

  1. 是否可以调用包含脚本的外部js文件?
  2. 是否可以从运行的js文件中包含另一个js文件?

mongodb

50
推荐指数
3
解决办法
8万
查看次数

C#Reflection - 从一个简单的类中获取字段值

我有一节课:

class A {
    public string a = "A-val" , b = "B-val";
}
Run Code Online (Sandbox Code Playgroud)

我想通过反射打印对象成员

//Object here is necessary.
Object data = new A();
FieldInfo[] fields = data.GetType().GetFields();
String str = "";
foreach(FieldInfo f in fields){
    str += f.Name + " = " + f.GetValue(data) + "\r\n";
}
Run Code Online (Sandbox Code Playgroud)

这是期望的结果:

a = A-val
b = B-val
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用.请帮忙,谢谢.

c# reflection

37
推荐指数
1
解决办法
7万
查看次数

找到int []数组中最受欢迎的元素

int[] a = new int[10]{1,2,3,4,5,6,7,7,7,7};
Run Code Online (Sandbox Code Playgroud)

我该怎么写一个方法并返回7?

我希望在没有列表,地图或其他助手的帮助下保持原生.只有数组[].

java arrays

37
推荐指数
5
解决办法
12万
查看次数

使用Automapper进行深层映射

我试图用多级成员映射对象:这些是类:

 public class Father
    {
        public int Id { get; set; }
        public Son Son { get; set; }
    }

    public class FatherModel
    {
        public int Id { get; set; }
        public int SonId { get; set; }
    }

    public class Son
    {
        public  int Id { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

这是我尝试自动化它的方式:

 AutoMapper.Mapper.CreateMap<FatherModel , Father>()
                      .ForMember(dest => dest.Son.Id, opt => opt.MapFrom(src => src.SonId));
Run Code Online (Sandbox Code Playgroud)

这是我得到的例外:

表达式'dest => Convert(dest.Son.Id)'必须解析为顶级成员而不是任何子对象的属性.请在子类型或AfterMap选项上使用自定义解析程序.参数名称:lambdaExpression

谢谢

c# automapper

28
推荐指数
3
解决办法
3万
查看次数

.net core 3 在 AddJsonOptions 中没有 ReferenceLoopHandling

我的 csproject 文件表明: <TargetFramework>netcoreapp3.0</TargetFramework>

在我的启动中,我使用以下内容:

 services.AddMvc(x => x.Filters.AddService<TransactionFilter>())
        .AddJsonOptions(options => options.JsonSerializerOptions... )
Run Code Online (Sandbox Code Playgroud)

但是, ReferenceLoopHandling 内部不可用options.JsonSerializerOptions

在此处输入图片说明

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="FluentNHibernate" Version="2.1.2" />
    <PackageReference Include="FullContact.Contacts.API" Version="1.0.3" />
    <PackageReference Include="Google.Cloud.Storage.V1" Version="2.3.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
    <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.5.0" />
    <PackageReference Include="MySql.Data" Version="8.0.17" />
    <PackageReference Include="piplclient" Version="5.0.9" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
  </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

json asp.net-core

25
推荐指数
3
解决办法
3万
查看次数

Visual Web开发人员 - 控制台应用程序,如何

我正在学习可视化Web开发人员c#,实体框架和webservices.
我希望能够运行实体框架,例如不构建gui,或运行浏览器.所以吊点申请参考可以做到这一点.我可以在Visual Web开发人员解决方案中添加控制台应用程序吗?

谢谢

c# visual-web-developer console-application

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

ASP.NET - 指定的网络密码不正确

我在我的开发机器上有一个需要证书的WCF客户端,它工作正常.
部署到生产服务器后,我收到以下错误:

[CryptographicException: The specified network password is not correct.]
Run Code Online (Sandbox Code Playgroud)

DEV - Win7 32BIT IIS 7.5
生产 - Win SERVER 64BIT 2008 IIS 7.5

即使网络之间没有密码也没有证书密码.(我知道因为开发工作没有密码).我唯一的密码是WCF,它与DEV相同.

CrmServiceClient crm = new CrmServiceClient("CrmServiceEndpoint");
crm.ClientCredentials.UserName.UserName = CrmConfigRepository.CrmUserName;//fine
crm.ClientCredentials.UserName.Password = CrmConfigRepository.CrmPassword;//fine
crm.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(Path);
///THIS WONT WORK AS WELL
crm.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(Path, "", X509KeyStorageFlags.Exportable); 
Run Code Online (Sandbox Code Playgroud)

这是完整的堆栈

[CryptographicException: The specified network password is not correct. ]
   System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +41
   System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0
   System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags …
Run Code Online (Sandbox Code Playgroud)

.net c# certificate

19
推荐指数
3
解决办法
3万
查看次数

ASP.NET - Ajax.BeginForm OnSuccess使用params回调

我想在我的OnSuccess回调中添加更多参数(但保留ajax上下文变量).
我做的是:

 using (Ajax.BeginForm("Register", new AjaxOptions() {
   OnSuccess = "new function(arg){HandleBasicForm(arg , 'MyCustomVariable')}",
    ...
Run Code Online (Sandbox Code Playgroud)

JS功能:

function HandleBasicForm(ajaxContext , myCustomVariable){
            var content = ajaxContext.get_response().get_object();
            ....
        }
Run Code Online (Sandbox Code Playgroud)

但是ajaxContext没有.
我怎么做?

.net c# ajax callback

13
推荐指数
2
解决办法
3万
查看次数

ASP.NET + C#HttpContext.Current.Session为null(Inside WebService)

这是我发起会议的方式

 protected void Session_Start(object sender, EventArgs e)
    {
        HttpContext.Current.Session["CustomSessionId"] = Guid.NewGuid();
    }
Run Code Online (Sandbox Code Playgroud)

在我的类库中的解决方案中,我正在访问它并获得null异常:

string sess = HttpContext.Current.Session["CustomSessionId"] ;
Run Code Online (Sandbox Code Playgroud)

这是我在web.config和app.config中的配置(在我的库中)

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
  <system.web>
      <pages enableSessionState = "true" />
      <httpModules>
        <add type="System.Web.SessionState.SessionStateModule" name="Session"/>
      </httpModules>
      <compilation debug="true" targetFramework="4.0" />
    </system.web>
Run Code Online (Sandbox Code Playgroud)

(app.config)中

c# asp.net session null

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