本文介绍了在"&安培;"字符分解存储在web.config密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS 7.5上运行的ASP.NET MVC3 C#.NET应用程序。

I have an ASP.NET MVC3 C# .NET Application running on IIS 7.5.

我们有我们冒充我们的code,以读/写文件到文件共享Windows NT服务帐户。用户ID被编译在code和服务帐户密码存储在web.config文件。

We have a Windows NT service account we Impersonate in our code in order to read/write documents to a file share. The user id is compiled in the code and the service account password is stored in the web.config file.

密码包含&字符(例如: P&放大器;提供ssword )。

The password contains an ampersand character (i.e.: p&ssword).

这打破了现场。当访问我们收到此错误的网站:抱歉,在处理您的请求时发生了错误。

This broke the site. When accessing the site we received this error :"Sorry, an error occurred while processing your request".

下面是使用密码code:

Here is the code that uses the password:

    var password = ConfigurationManager.AppSettings.Get(Common.SVC_PWD);

    bool isSuccess = LogonUser(
        @"my_svc_acct",
        "my.domain.net",
        password,
        LOGON32_LOGON_NEW_CREDENTIALS,
        LOGON32_PROVIDER_DEFAULT, ref token
    );

为什么会变成这样导致站点突破?

Why would this cause the site to break?

推荐答案

我怀疑你没有连接$ C C密码$正确的的web.config 文件。请记住,的web.config 是一个XML文件,因此实体必须连接codeD。

I suspect that you didn't encode the password properly in the web.config file. Remember that web.config is a XML file, so entities must be encoded.

my&password

尝试

my&password

这篇关于在"&安培;"字符分解存储在web.config密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:30