View Complete Post
I need to encrypt SMTP settings in the app.config file.I also read
MSDN article that uses RSA also to encrypt/decrypt.
This is my code:
public class Program
private static void ProtectConfiguration()
// Get the application configuration file.
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Define the Rsa provider name.
string provideRsa = "RsaProtectedConfigurationProvider";
I'm all set on the server side with the RSA key pair installed. Where I'm hung up is trying to get the job done on the web.config file ... can't seem to get the aspnet_regiis command string right. I am using the command string provided by the web host (DiscountAsp.net). Most (all) of the examples I read use a website on the development machine. I actually registered my project in IIS and tried that but it didn't work. In any case I would rather not have to go to the hassle of registering a project in IIS anyway if I can avoid it.
My web application project is in a folder on my local machine:
This is most recent (failed) attempt to use aspnet_regiis:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pe "connectionStrings" "D:\Projects\<project name>"
Is it possible to just do this manually by looking at the NetFrameworkConfigurationKey_xxxxx.xml file and entering the values? Seems like it should be do-able except I'm not sure how to parse the xml file for the correct values.
On a related note, when I add the following code to web.config it "announces" that "The keyContainerName attribute is not allowed". Ditto useMachineContainer
We have website hosted on shared server with SQL Server 2005 as database. Now that database server is also shared by other people and hence we have to use SQL Server authentication and we have stored those connection strings in our web.config file.
Can we encrypt connection strings? I found few ways to encrypt but in all of them I have to have access to the server and that I don't have.
One of my NUnit tests has to read in some values from config files. In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in. Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work. Are there any special steps involved when reading from config files in an nunit test ?
Ive created an NUnit test project in my solution and have added 3 tests. They all fail with the same error
SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
----> System.NullReferenceException : Object reference not set to an instance of an object.
heres the test method
public void CreateDataContext_ConnectionString_ReturnsDataCon
Im trying to create a Web Deployment Project, the built in setup and deployment is very good in Visual Studio, i need to able to add an additional step in the setup to change the connection string in the Web config file. Ive seen a lot of articles on how to do this and in particular this http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx#7162670 I am however stuck on the final part of this tutorial, im using the code Scott provided but have two errors, heres part of my code where the errors are
void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
// Retrieve "Friendly Site Name" from IIS for TargetSite
DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSit
I have a web application that is actually installed as a component of a third party site. In some configurations, I need to remove certain connection strings and re-add them. I'm replacing this web.config section with a xml file that includes the following:
<connectionStrings> <remove name="MyOverridenConnection"/> <add connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDb;Data Source=MyServer" name="MyOverridenConnection" providerName="System.Data.SqlClient"/> </connectionStrings>
For some reason the remove tag is left out during the substitution and I end up with the following in the installed config:
<connectionStrings> <add connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDb;Data Source=MyServer" name="MyOverridenConnection" providerName="System.Data.SqlClient"/> </connectionStrings>
Is there any way to issue removes in replaced sec
Even though you've been using ASP. NET for a while, how much do you really know about ASP. NET configuration files? While you've probably touched the Web. config file from time to time, there are some nuances involved in configuring ASP.
MSDN Magazine September 2004
The Advanced Encryption Standard (AES) is a National Institute of Standards and Technology specification for the encryption of electronic data. It is expected to become the accepted means of encrypting digital information, including financial, telecommunications, and government data. This article presents an overview of AES and explains the algorithms it uses. Included is a complete C# implementation and examples of encrypting .NET data. After reading this article you will be able to encrypt data using AES, test AES-based software, and use AES encryption in your systems.
MSDN Magazine November 2003
I am working on a MVC project with Razor view engine and I have the following:
This only works if I have on the same view the following:
However, on my Web.Config I have the following:
<!-- Namespaces -->
So if "SquishIt.Framework" namespace is added on Web.Config why do I need to have the @using on the view?
Hi, I am very confused about encrypting and decrypting password.
What I did is that, I am using a class that extends SqlMembershipProvider, and when I need to encrypt a password, just called base.EncryptPassword() method to do so.
But still, I did not get to know how things are done here, and I really would like to know its codes.
Can anyone provide the code for me please?
I would like to secure any URL below the http://MyServer/Admins and limit it to a specific role.
In webforms it was straight forward. I just put a child web.config in the /Admin/ folder and add <authorization> <allow roles> tags to it.
How would be the equivalent technique in MVC?
I'm asking this question AFTER I've already solved my problem - I just wanted more info about it.
Each time I tried to create a ViewUserControl with a specific model template like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyProject.Web.ContactFormContent>" %>
The control would not compile properly and intellisense would not show things like Html and ViewData.
However, when I add the attribute pageParserFilterType to the <pages> in web.config, everything works:
please help - the problem is in post subject.
I have lots of warnings with following text:
"Warning 10 Element 'HyperLink' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing. C:\Users\Pavel\Documents\Visual Studio 2010\WebSites\BioWebSite\ToScientist.aspx 26 18 C:\...\BioWebSite\"
But web.confg is there! And there's no compilation error!
Site builds just fine. And If I upload it to my hoster - it works!
But with all these errors I cant add controls to pages - VS2010 adds hyperlink without ID, and intelisens stoped to work.
Strange, but in my other project (web-application) I have no such difficuty.
We have sepeartate folder called Managers in one of our web apps. And there was a security build around that folder in a web config file as below
<?xml version="1.0"?><configuration> <appSettings/> <connectionStrings/> <system.web> <authorization> <allow roles="AllManagers"/> <deny users="*"/> </authorization> </system.web></configuration>
I couldn't figure out where this group located in the application. Usually all our groups are defined in Active directory but except this group. I am not sure if this is defined on the web server or some where in the app itself. Because in the process of figuring out I have changed it to <allow users="*"/> just to make sure if this is the group we are looking for and YES It is and I have access to it. So I need to find out where this is located and add myself as one of the users to this group.
Can any one help me with this mystery.
Thanks in advance,