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

Post New Web Links

URL Rewrite causes AppSettings to Fail?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi there,

I just implemented basic URL rewriting to change a page from, for example, /member.aspx?id=123 to /member.aspx/erik.  That works and I'm happy with it.  However, I am now getting an error message that states "the connectionstring property has not been initialized".  Normally, I've been storing the connectionstring in web.config, and I access it with:

Dim Connect As SqlConnection = New SqlConnection
Dim ConnectString As String
ConnectString = ConfigurationManager.AppSettings("linktomysite")
Connect.ConnectionString = ConnectString

This is what I do on every other page of the site and it works fine.  The only way it will work on the page where I'm URL re-writing, however, is if I replace "ConfigurationManager.AppSettings("linktomysite")" with the actual connection string itself.  For security reasons, obviously I would prefer to keep that info out of the page.  What can I do?



View Complete Post

More Related Resource Links

Appsettings config section in web.config cause WCFTestClient to fail

i have a WCf project, when i add the following code to the configuration file (Web.config): <configuration> <appSettings> <add key="hello" value="Monday" /> </appSettings> ..... ... .... i get this error when trying to debug: "Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information." when i drop the appsettings, the WCFTestClient opens. how do i define constants in the web.config if not in that way ?

Url rewrite with timer



I'm trying to rewrite my urls, which kinda work now.

The problem is that in my page i'm using a timer to refresh the data every couple of seconds.
But in Mozilla firebug I can see that the url keeps changing: it's getting bigger after each timer update, like this:


etc etc, until it returns a 404 not found.

What can I do to prevent this?


Arabic QueryString with Url Rewrite Solution


Alsalamo 3alaykom ,

as we know that if you use Intelligencia.UrlRewriter.RewriterHttpModule or IIS URL Rewriting , we will face problems with arabic urls

as this

http://localhost:1234/Pages/???? ?????? ?????? ??????????

and the Rule is :

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

you will recive the QueryString["Page"] Like this

نائب العميد للشؤون الأكاديمية

so it's a big problem , and there is a solution that is :

remove the Rule of that rewriting ,,

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

then open your Global.asax file and Application_BeginRequest method exactly

use the following code to handle you request

void Application_BeginRequest(object sender, EventArgs e)
if (HttpContext.Current.Request.Url.ToString().Contains("/Pages/"))
	String[] txt= Regex.Split(HttpContext.Current.Request.Url.ToString(), @"/");
	String page = txt[txt.Length-1];

.NET Internals: Rewrite MSIL Code on the Fly with the .NET Framework Profiling API


In this article, the author shows how to dynamically rewrite Microsoft Intermediate Language code on the fly using the Profiling API of the CLR. Unlike approaches based on Reflection.Emit, this scheme works with the existing assemblies and doesn't require the creation of proxy or dynamic assemblies. The need for IL code rewriting emerges when you want to make your changes transparent to the client and preserve the identity of classes. This technique can be used for creation of interceptors, pre- and post-processing method calls, and code instrumentation and verification.

Aleksandr Mikunov

MSDN Magazine September 2003

Want to create Page URL rewrite based on Users GUID and Display name?



I am using the asp.net membership. 

On my site I have a Profile.aspx page.

In the code behind of this page,  i get the logged in UserId (Guid) and pass

this to a method in my DAL. GetUserByUserId()


In my database I have a Table called Member which the method gets the data from

and displays details on the page about  the user.


What I want to happen is when they have logged in and are diverted to Profile.aspx,

the page URL shows www.MyWebSite/Profile/UsersName 

for example



is this possible. In my Member table I have FirstName and LastName columns or do I get the

name from the membership table.


even better would be they go straight to www.MyWebsite/JohnSmith.aspx


thank you for any help






Url Rewrite for web service ...


Hello ,

how i can rewrite url for an web service ?!

i use it :

<add name="WebService" virtualUrl="^~/include/(.*).do" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Def/WebService/$1.asmx" ignoreCase="true"/>

but when run sie , get some error(405 (Method Not Allowed) OR 500 ..) ...

Now I need to how to rewrite the web service address.

please help me ...

thanks .

$.ajax post from asp.net page and __viewstate causing call to fail



Now I know that I won't be sending viewstate and eventvalidation in my ajax calls and that I will only want to send the actual form fields for efficiency purposes but I will need to know the answer to this question, to inform the more junior members of the team and my manager, so if anyone has any answers they are most welcome.

I have a simple form as follows

<form id="form1" runat="server"> 
<p>Field1: <

Url Rewrite


Hi Everyone,

I have used url rewrite before, but have not yet attempted to do the following.
I have one site (www.somesite.co.za) which is being 301'ed to (www.sub.someothersite.co.za).
This work fine of course.

Is it possible to actually change the domain name in the url re-write? I would like to
hide the fact that the user is actually on a sub site on another domain. For example
if you browse to www.somesite.co.za, the url now reads www.subsite.someothersite.co.za.
I would like to re-write it to still be www.somesite.co.za

Any help will be greatly appreciated.

Thank you


Louis Lewis 

VS 2010 XAML Design View Load always fail with a Type Load Exception

Create a new WPF project in VS and change nothing. The Design View will fail to load with the error below. Error    1    Could not load type 'Microsoft.Expression.DesignModel.Core.ISharedInstanceBuilder' from assembly 'Microsoft.Expression.DesignModel, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Microsoft.Expression.DesignModel is an assembly from Expression Blend. I ever installed Blend 4 RC and uninstall and install Blend 4. I Reflector the assembly I have under Blend 4 bin folder. And cannot find a interface named ISharedInstanceBuilder. But the WPF project is a Template project without any changes. How it get related with Blend 4? And how to fix it? Thanks.  

Url Rewrite for web service ...

Hello , how i can rewrite url for an web service ?! i use it :   <add name="WebService" virtualUrl="^~/include/(.*).do" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Def/WebService/$1.asmx" ignoreCase="true"/>  but when run site and call a method(webservice.asmx/ChangeImage) , get error :The resource cannot be found. and if call web service mathod with jquery get error(405:Method Not Allowed). this is replay : <html> <head> <title>The HTTP verb POST used to access path '/Game-Root/Def/WebService/webservice.asmx/ChangeImage' is not allowed.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:

How to make SSIS Package Fail when something goes wrong

Hello, Is there any way I can make the package (SSIS 2005) fail when something happen? Like: if some value become zero I will to make the package fail from with in the SSIS, so that the AgentJOB  that started this package will know? Thanks, Prabhat Nath

Transactional Publication With Article Using DATE Datatype Causes Snapshot Agent to Fail with Error

So I am using SQL Server 2008 Enterprise Edition (64Bit) and have run into a strange problem that is baffling me. I have two tables that I need to replicate.  They are identical in specification except the name (one is for monthly stats and one daily stats) CREATE TABLE [dbo].[statsDailyLite]( [EntryDate] [date] NOT NULL, [SetID] [int] NOT NULL, [ProductID] [smallint] NOT NULL, [Hooks] [int] NOT NULL, [AdViews] [int] NOT NULL, [Clicks] [int] NOT NULL, [UAdViews] [int] NOT NULL, CONSTRAINT [PK_statsDailyLite] PRIMARY KEY CLUSTERED ( [EntryDate] ASC, [SetID] ASC, [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ) GO CREATE TABLE [dbo].[statsMonthlyLite]( [EntryMonth] [date] NOT NULL, [SetID] [int] NOT NULL, [ProductID] [smallint] NOT NULL, [Hooks] [int] NOT NULL, [AdViews] [int] NOT NULL, [Clicks] [int] NOT NULL, [UAdViews] [int] NOT NULL, CONSTRAINT [PK_statsMonthlyLite] PRIMARY KEY CLUSTERED ( [EntryMonth] ASC, [SetID] ASC, [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ) GO They both conatin a thousand or so test rows of data, and they are both in a transactional publication going to another SQL 2008 box. Now when the tables are empty

Distributed Transactions fail on Linked server

We get the below error while performing a distributed transaction on linked server. We have several linked servers configured in the source server and all of them succeed with the distributed transaction except on one.   We did all the basic troubleshooting and moreover the distributed transactions work fine if we use a remote server instead.   Need your expert guidance in resolving this issue     Error:   OLE DB provider "SQLNCLI10" for linked server "SERVERNAME.REDMOND.CORP.MICROSOFT.COM" returned message "No transaction is active.". Msg 7391, Level 16, State 2, Line 3 The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "SERVERNAME.REDMOND.CORP.MICROSOFT.COM" was unable to begin a distributed transaction.     Test code:   begin distributed transaction   select top 10 * from [SERVERNAME.REDMOND.CORP.MICROSOFT.COM].master.sys.objects   ROLLBACK     Source server :      Microsoft SQL Server 2008 (RTM) - 10.0.1779.0 (X64)        Nov 12 2008 12:10:04        Copyright (c) 1988-2008 Microsoft Corporation        Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6001: Service Pack 1) (VM)     Target server :     Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)        Jul  9 2008 14:43:34        Copyright (c) 1988-2008 Microsoft Corporation        Enterprise Edition

Referencing ConfiguratingSettings.AppSettings in a ASCX user control?

Hi there,I'm trying to reference a string from the web.config file from a ASCX user control, but I get the error message: [b]Compiler Error Message: BC30203: Identifier expected.My code in the user control file is as follows:<div id="header"><h1><%= Server.HtmlEncode(Convert.ToString(ConfigurationSettings.AppSettings["Web_Title"])) %></h1></div>Do I need to import any namespaces? Hopefully someone can help!Thanks

URL-rewrite problem or sth else?

WelcomeI have a little problem with the *. js and *. css (probably also with others). When they move up to the header (or anywhere) I get something like that. Any ideas?Tuinel

Upload File through SQL reporting manager fail

Hi Support, I encounter error message when I upload the .rdl file at SQL report manager. The error message as below: The report definition is not valid. Details: '.', hexadecimal value 0x00, is an invalid character. Line 700, position 10. (rsInvalidReportDefinition) The server we are running on version: Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)   Mar 29 2009 10:11:52   Copyright (c) 1988-2008 Microsoft Corporation  Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) Does SQL 2008 standard sp1 support SQL reporting services? Appreciate if someone know the answers, Thank You! Regards, SiewHiong    

asp:LoginStatus with url rewrite - postback url

hi ! I have done a url rewrite in my website and I did the following for handling the postbacks;    protected void Page_Load(object sender, EventArgs e)     {         this.form1.Action = Request.RawUrl;    protected void Page_Load(object sender, EventArgs e)    {        this.form1.Action = Request.RawUrl;it worked. but no with loginstatus button?? anyone knows why??
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