.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Problem with web.config encryption

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net


I'm trying to encrypt the <connectionStrings> in my web.config site using this code:

protected void btnProtect_OnClick(object sender, EventArgs e)
        ProtectSection("connectionStrings", "DataProtectionConfigurationProvider");


    private void ProtectSection(string sectionName, string provider)
        Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

        ConfigurationSection section =

        if (section != null &&

I'm getting this error message:

Failed to map the path '/'.

on this line:

Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);


View Complete Post

More Related Resource Links

Razor View Engine and Add Namespace in Web.Config Problem



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:

  @using SquishIt.Framework;

However, on my Web.Config I have the following:


      <!-- Namespaces -->
        <add namespace="System"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="Microsoft.Web.Mvc"/>
        <add namespace="SquishIt.Framework"/>


So if "SquishIt.Framework" namespace is added on Web.Config why do I need to have the @using on the view?

Problem when using Activator.CreateObject and reading App.Config file

Hello, this is the scenario. I have an application that load at runtime severals dll. these dll are actually "adapters" that wraps calls to web services, database and so on. The app.config of the "main" application stores in config sections all information necessary to each adapter (i.e.Web ServiceURL..) and I have created inside each adapter a class to ready those values the loading at run time the DLL has been implemented by storing all necessary types into a dictionary of generics and when I need to instanciate it I call the Activate.CreateObject and I pass the specific type (I means the name of the Adapter class) The problem is that the adapter class itself is not able to get the config value because ConfigSection has not been initialized. If I write: IInterfaceAdap adapt = new myAdapter() -> I read the config data IInterfaceAdap adapt = (IInterfaceAdap)Activator.CreateObject (type) -> now way to read the data stored in the App.Config. I think that I undertood the problem but I'm not able to find a workaround to read data store in the app.config!! I need help please!!  

problem reading from app.config


I have added an app.config file in my winform aplicaion an added one key

<add key="IsFirstRun" value="True" />

then I am tying to read it like this:


but I am getting this error:

Configuration system failed to initialize

on the MessageBox line..

why? how ca I fix please?

Jassim Rahma

String encryption problem with request.querystring (urlencode/decode)


I need to pass a userid as a guid number through a url quesrystring

 my starting GUID is in string format =  "23c6e6a5-e9fc-4fd0-aa15-e5db9b900388"

1) I encrypt it using tripledes

the resulting string value =  "nJYKpGwOeoOWepKPSDyNnO+xk+ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

if I immeadiately decrypt it get the expected original value (so my tripledes provider is working)

2) I then urlencode the value for placing into the url which results in:

urlencoded = "nJYKpGwOeoOWepKPSDyNnO%2bxk%2bZcfYZnyxvAnKTNCMV%2fZJ7CfDKcmA%3d%3d"

3) when a read it back from the url using Request.QueryString (a function which automatically decodes the value)

I get the value: "nJYKpGwOeoOWepKPSDyNnO xk ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

It appears the "+" characters where replaced with " "

This incorrect value caused the tripledes decryption to fail.
I am using VS 2010 Framework 4.0, IIS7, IE8 and the System.Security.Cryptography.TripleDESCryptoServiceProvider

Is this a bug or am I doing something wrong. It appears the the problem is with the urlencode or the embeded urldecode which is part of request.querystring

Many thanks for any assistance in how to resolve this.


web.config problem


I have a subdomain mobile.JassimRahma.com and that's referring of course to a folder on my root called mobile.

I just created a simple, very simple Default.aspx file and placed in the mobile folder but I am getting thie error:

Runtime Error 
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".



and this is my SIMPLE Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Jassim.mobile.Default" %>
<%@ OutputCache Duration="120" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD

Cracking asp.net encryption -> web.config


Um...how does one go from cracking some encryption to downloading a web.config?  Surly IIS just plain won't serve up a web.config file?

(I'm not after a step by step - but it seems completely random to go from getting some knowlage about a cipher to downloading my web.config)

web.config connection string problem within VisualStudio 2010 to point to SQL Server 2008 R2 Develop


Hello All, I would appreciate any help with this.

I believe my problem exists within the web.config which already had code in it to connect to SQL Server Express 2008.

I uninstalled the SQL Server Express that came with Visual Studio 2010.

I installed SQL Server 2010 R2 Developer, and I'm able to connect via Management Studio and through Visual Studio's Server Explorer's Data Connections I am connected.

I did run aspnet_regsql.exe within the 4.0 folder in order to create the database with Microsoft Service Providers.

Here is the ServerName: USER-5529234649 

Here is the name of the DataBase:  StepByStepChapter9

Here is the name of the Connection within Visual Studio's Server Explorer's Data Connections:  user-5529234649.StepByStepChapter9.dbo

Here is the code I changed in the web.config:

<add name="ApplicationServices" c

Problem in the Console Applications app.config file for .NET 4.0



I am developing a console application.  I am going to use that in 3 environments. I have placed a key in the appsetting section and i am expecting the value to be overwritten by the respective config file specified during the build time.

    <appSettings file="Stage.config">
        <add key="DataConfiguration.ActiveLocation" value="Production"/>
        <add key =name="Dev.Local" providerName="System.Data.SqlClient" connectionString="data source=Test\SQLSERVER2005;initial catalog=ABCD;user id=admin;password=asdh511"/>

And the Stage.config values are

<add key="DataConfiguration.ActiveLocation" value="Staging"/>


encryption and decryption is web.config


Hi there,

I walk through this article about encryption and decryption http://msdn.microsoft.com/en-us/library/2w117ede.aspx

but if i move my encrypted application to another server  i can decrypt it easily using the following command :

aspnet_regiis -pd " connectionStrings" -app "/myapplication"

so anyone who knows this command can decrypt it easily. so what is the use of the rsa key in this case.

how can i prevent anyone from decrypting my web.config

thxs for ur help

Merge Replication using Web Sync - Proxy Auto config problem



I am trying to setup merge replication using web sync. I  keep on getting the message: The Proxy Auto-configuration URL was not found. Yes I have read all the postings telling me to check my internet explorer settings concerning proxy server and auto-detection - I am not using a proxy - auto detection is unchecked.

Does anyone have another clue?



2006-08-16 15:31:09.375 Connecting to Subscriber 'CRAW'
2006-08-16 15:31:09.437 Connecting to Subscriber 'CRAW'
2006-08-16 15:31:09.453 The upload message to be sent to Publisher 'CRAW' is being generated
2006-08-16 15:31:09.453 The merge process is using Exchange ID '20E2BF4F-8812-431F-8BF8-94A44B80C16E' for this web synchronization session.
2006-08-16 15:31:09.500 The Proxy Auto-configuration URL was not found.

Clean Web.Config Files (VS 2010 and .NET 4.0 Series)

.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).

The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we've added over the years, including the functionality for:

.ASP.NET Dynamic Data
.ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
.ASP.NET Chart Control (which now ships built-into ASP.NET V4)
What this means is that when you create a new "Empty ASP.NET application" project in VS 2010, you'll find that the new default application-level web.config file is now clean and simple:

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Regrading Sharpoint 2010 problem and solutions

We can write your question and problem on this blogger.you get ans.use.

This sharpoint 2010 problem solving threads

Hi friend,

you can use this thread to solving problem and solutions.

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Strange Photo upload problem


I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance

ASP.Net Caching problem ??


I'm having a problem with an asp.net 3.0 application using a gridview to display data.  The problem seems to be that despite a brand new .selectCommand being sent to the sqlDataSource, the gridview starts displaying data from *someone else's* query.  For example, user A is logged in and will be working fine until a few page submissions later when the gridview data starts suddenly showing information that belongs to another user. 

This is my first asp.net application, though I've been working with classic asp and ADO for years so I'm used to sending a SQL string and getting back the results from that string.  Apparently there is a complex caching system which is interferring which I do not at all understand so at this point I just want to stop the server from caching any data whatsoever.  Is this possible?

Any and all help will be much appreciated!!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend