By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

problem reading web.config's <configSection> - returns null

P: n/a
Hi all.

i'm tryng to implement the Rewrite.NET url rewritining functionality into a
test project i've created, however i am hitting a problem at this line
(direct from the web example):

System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.ConfigurationSettings.GetCo nfig("Rewrite.NET/Index");

The value always returns me null, and just to check it was reading from the
same web.config, i added a, appSettings value which i could read fine.

These code examples are directly off the web example and nothing is changed,
however the above call to find "GetConfig" section returns null and i dont
know why?? any help appreciated!

Here is what my web.config looks like:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx" />
<add key="/Default.aspx?page=Contact" value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>

thanks,
Paul
Mar 12 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Mar 12, 9:11 am, "Milsnips" <milsn...@hotmail.comwrote:
Hi all.

i'm tryng to implement the Rewrite.NET url rewritining functionality intoa
test project i've created, however i am hitting a problem at this line
(direct from the web example):

System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co*nfigurationSettings.GetC onfig("Rewrite.NET/Index");

The value always returns me null, and just to check it was reading from the
same web.config, i added a, appSettings value which i could read fine.

These code examples are directly off the web example and nothing is changed,
however the above call to find "GetConfig" section returns null and i dont
know why?? any help appreciated!

Here is what my web.config looks like:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx" />
<add key="/Default.aspx?page=Contact" value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>

thanks,
Paul
I'm not sure, but what does "Index" mean in "Rewrite.NET/Index"?

Mar 12 '07 #2

P: n/a
Aah yes, that was the problem, there was a missing line in web.config with
name "Index" within the group section.
thanks,
Paul

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
On Mar 12, 9:11 am, "Milsnips" <milsn...@hotmail.comwrote:
Hi all.

i'm tryng to implement the Rewrite.NET url rewritining functionality into
a
test project i've created, however i am hitting a problem at this line
(direct from the web example):

System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co*nfigurationSettings.GetC onfig("Rewrite.NET/Index");

The value always returns me null, and just to check it was reading from
the
same web.config, i added a, appSettings value which i could read fine.

These code examples are directly off the web example and nothing is
changed,
however the above call to find "GetConfig" section returns null and i dont
know why?? any help appreciated!

Here is what my web.config looks like:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx" />
<add key="/Default.aspx?page=Contact"
value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>

thanks,
Paul
I'm not sure, but what does "Index" mean in "Rewrite.NET/Index"?
Mar 12 '07 #3

P: n/a
Just one more question regarding url rewriting -

In my code example i put a rule, say "Default.aspx?id=4" - rewrite to
"products/default.aspx", and as i step through the code i can see it does
everything correctly, but when it gets to displaying the page, it says
"products/default.aspx not found"!

I assumed this just rewrote the name virtually that appears on the page
links/ or address bar, but not actually physically redirect to the location?

Have i misunderstood something here?
thanks,
Paul

"Milsnips" <mi******@hotmail.comwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all.

i'm tryng to implement the Rewrite.NET url rewritining functionality into
a test project i've created, however i am hitting a problem at this line
(direct from the web example):

System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.ConfigurationSettings.GetCo nfig("Rewrite.NET/Index");

The value always returns me null, and just to check it was reading from
the same web.config, i added a, appSettings value which i could read fine.

These code examples are directly off the web example and nothing is
changed, however the above call to find "GetConfig" section returns null
and i dont know why?? any help appreciated!

Here is what my web.config looks like:

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx" />
<add key="/Default.aspx?page=Contact" value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>

thanks,
Paul


Mar 12 '07 #4

P: n/a
On Mar 12, 9:31 am, "Milsnips" <milsn...@hotmail.comwrote:
Just one more question regarding url rewriting -

In my code example i put a rule, say "Default.aspx?id=4" - rewrite to
"products/default.aspx", and as i step through the code i can see it does
everything correctly, but when it gets to displaying the page, it says
"products/default.aspx not found"!

I assumed this just rewrote the name virtually that appears on the page
links/ or address bar, but not actually physically redirect to the location?

Have i misunderstood something here?
thanks,
Paul

"Milsnips" <milsn...@hotmail.comwrote in message

news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all.
i'm tryng to implement the Rewrite.NET url rewritining functionality into
a test project i've created, however i am hitting a problem at this line
(direct from the web example):
System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co*nfigurationSettings.GetC onfig("Rewrite.NET/Index");
The value always returns me null, and just to check it was reading from
the same web.config, i added a, appSettings value which i could read fine.
These code examples are directly off the web example and nothing is
changed, however the above call to find "GetConfig" section returns null
and i dont know why?? any help appreciated!
Here is what my web.config looks like:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx" />
<add key="/Default.aspx?page=Contact" value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>
thanks,
Paul- Hide quoted text -

- Show quoted text -
It looks like you forgot to add a configuration line for

products/default.aspx

into web.config.

I think you should check the manual for software you used (I don't
know what Rewrite.NET is)

Mar 12 '07 #5

P: n/a
Rewrite.NET is some free code on the web to handle url rewriting in
asp.net - link: http://www.15seconds.com/issue/030522.htm

Anyway, to test my example i added the line in web.config:
<add key="/Default.aspx?id=4" value="/products/default.aspx" />

So, when i run it, i type in "localhost/project/default.aspx?id=4" and it
goes through the rules and finds it and calls the function:
Appl.Context.RewritePath("/products/default.aspx"); and here i get the 404
error saying page not found.

I thought that it was just meant to virtually rename the page url, but in
the background still use "default.aspx?id=4" ??

regards,

Paul

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@30g2000cwc.googlegro ups.com...
On Mar 12, 9:31 am, "Milsnips" <milsn...@hotmail.comwrote:
Just one more question regarding url rewriting -

In my code example i put a rule, say "Default.aspx?id=4" - rewrite to
"products/default.aspx", and as i step through the code i can see it does
everything correctly, but when it gets to displaying the page, it says
"products/default.aspx not found"!

I assumed this just rewrote the name virtually that appears on the page
links/ or address bar, but not actually physically redirect to the
location?

Have i misunderstood something here?
thanks,
Paul

"Milsnips" <milsn...@hotmail.comwrote in message

news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all.
i'm tryng to implement the Rewrite.NET url rewritining functionality
into
a test project i've created, however i am hitting a problem at this line
(direct from the web example):
System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co*nfigurationSettings.GetC onfig("Rewrite.NET/Index");
The value always returns me null, and just to check it was reading from
the same web.config, i added a, appSettings value which i could read
fine.
These code examples are directly off the web example and nothing is
changed, however the above call to find "GetConfig" section returns null
and i dont know why?? any help appreciated!
Here is what my web.config looks like:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx"
/>
<add key="/Default.aspx?page=Contact"
value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>
thanks,
Paul- Hide quoted text -

- Show quoted text -
It looks like you forgot to add a configuration line for

products/default.aspx

into web.config.

I think you should check the manual for software you used (I don't
know what Rewrite.NET is)
Mar 12 '07 #6

P: n/a
On Mar 12, 10:13 am, "Milsnips" <milsn...@hotmail.comwrote:
Rewrite.NET is some free code on the web to handle url rewriting in
asp.net - link:http://www.15seconds.com/issue/030522.htm

Anyway, to test my example i added the line in web.config:
<add key="/Default.aspx?id=4" value="/products/default.aspx" />

So, when i run it, i type in "localhost/project/default.aspx?id=4" and it
goes through the rules and finds it and calls the function:
Appl.Context.RewritePath("/products/default.aspx"); and here i get the 404
error saying page not found.

I thought that it was just meant to virtually rename the page url, but in
the background still use "default.aspx?id=4" ??

regards,

Paul

"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message

news:11**********************@30g2000cwc.googlegro ups.com...
On Mar 12, 9:31 am, "Milsnips" <milsn...@hotmail.comwrote:


Just one more question regarding url rewriting -
In my code example i put a rule, say "Default.aspx?id=4" - rewrite to
"products/default.aspx", and as i step through the code i can see it does
everything correctly, but when it gets to displaying the page, it says
"products/default.aspx not found"!
I assumed this just rewrote the name virtually that appears on the page
links/ or address bar, but not actually physically redirect to the
location?
Have i misunderstood something here?
thanks,
Paul
"Milsnips" <milsn...@hotmail.comwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all.
i'm tryng to implement the Rewrite.NET url rewritining functionality
into
a test project i've created, however i am hitting a problem at this line
(direct from the web example):
System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co**nfigurationSettings.Get Config("Rewrite.NET/Index");
The value always returns me null, and just to check it was reading from
the same web.config, i added a, appSettings value which i could read
fine.
These code examples are directly off the web example and nothing is
changed, however the above call to find "GetConfig" section returns null
and i dont know why?? any help appreciated!
Here is what my web.config looks like:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx"
/>
<add key="/Default.aspx?page=Contact"
value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>
thanks,
Paul- Hide quoted text -
- Show quoted text -

It looks like you forgot to add a configuration line for

products/default.aspx

into web.config.

I think you should check the manual for software you used (I don't
know what Rewrite.NET is)- Hide quoted text -

- Show quoted text -
Paul, what the URL you want to rewrite?

As I understood, you have a page named default.aspx, located in /
project

So, the URL

http://localhost/project/default.aspx?id=4

should work somehow without any rewriting engine.

The Rewrite.NET is designed to make

http://localhost/products/default.aspx or http://localhost/project/products/default.aspx

working as

http://localhost/project/default.aspx?id=4

So, you should call http://localhost/products/default.aspx or
http://localhost/project/products/default.aspx to get it working.

As second, you page is under "/project" and the config key refer to
"/"

<add key="/Default.aspx?id=4" value="/products/default.aspx" />

Mar 12 '07 #7

P: n/a
Hi Alexey,

Thanks for the info, yes i understand what you mean however this is what i
am trying to achieve..
"
say i have a online store with dynamic product list, instead of my page
showing http://onlinestore/shop/product.aspx?id=25, I want to show:
http://onlinestore/shop/25/nokia-6610.htm

I've seen it on many sites and im pretty sure that nokia-6610 is a
non-existant file, just a virtual redirection from products.aspx?id=25 - if
you know what i'm after.

thanks,
Paul
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
On Mar 12, 10:13 am, "Milsnips" <milsn...@hotmail.comwrote:
Rewrite.NET is some free code on the web to handle url rewriting in
asp.net - link:http://www.15seconds.com/issue/030522.htm

Anyway, to test my example i added the line in web.config:
<add key="/Default.aspx?id=4" value="/products/default.aspx" />

So, when i run it, i type in "localhost/project/default.aspx?id=4" and it
goes through the rules and finds it and calls the function:
Appl.Context.RewritePath("/products/default.aspx"); and here i get the
404
error saying page not found.

I thought that it was just meant to virtually rename the page url, but in
the background still use "default.aspx?id=4" ??

regards,

Paul

"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message

news:11**********************@30g2000cwc.googlegro ups.com...
On Mar 12, 9:31 am, "Milsnips" <milsn...@hotmail.comwrote:


Just one more question regarding url rewriting -
In my code example i put a rule, say "Default.aspx?id=4" - rewrite to
"products/default.aspx", and as i step through the code i can see it
does
everything correctly, but when it gets to displaying the page, it says
"products/default.aspx not found"!
I assumed this just rewrote the name virtually that appears on the page
links/ or address bar, but not actually physically redirect to the
location?
Have i misunderstood something here?
thanks,
Paul
"Milsnips" <milsn...@hotmail.comwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all.
i'm tryng to implement the Rewrite.NET url rewritining functionality
into
a test project i've created, however i am hitting a problem at this
line
(direct from the web example):
System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollectio n)System.Configuration.Co**nfigurationSettings.Get Config("Rewrite.NET/Index");
The value always returns me null, and just to check it was reading
from
the same web.config, i added a, appSettings value which i could read
fine.
These code examples are directly off the web example and nothing is
changed, however the above call to find "GetConfig" section returns
null
and i dont know why?? any help appreciated!
Here is what my web.config looks like:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="Rewrite.NET">
<section name="SimpleSettings"
type="System.Configuration.NameValueSectionHandler ,System" />
</sectionGroup>
</configSections>
<Rewrite.NET>
<SimpleSettings>
<!-- sample test page urls to rewrite -->
<add key="/Default.aspx?page=Home" value="/default.aspx" />
<add key="/Default.aspx?page=About" value="/about.aspx"
/>
<add key="/Default.aspx?page=Contact"
value="/contact.aspx"
/>
</SimpleSettings>
</Rewrite.NET>
<appSettings>
<add key="test" value="test"></add>
</appSettings>
<connectionStrings/>
<system.web>
<httpModules>
<add type="Rewrite.NET.Rewrite,Rewrite.NET"
name="Rewrite.NET" />
</httpModules>
<compilation debug="true" />
<authentication mode="Windows" />
</system.web>
</configuration>
thanks,
Paul- Hide quoted text -
- Show quoted text -

It looks like you forgot to add a configuration line for

products/default.aspx

into web.config.

I think you should check the manual for software you used (I don't
know what Rewrite.NET is)- Hide quoted text -

- Show quoted text -
Paul, what the URL you want to rewrite?

As I understood, you have a page named default.aspx, located in /
project

So, the URL

http://localhost/project/default.aspx?id=4

should work somehow without any rewriting engine.

The Rewrite.NET is designed to make

http://localhost/products/default.aspx or
http://localhost/project/products/default.aspx

working as

http://localhost/project/default.aspx?id=4

So, you should call http://localhost/products/default.aspx or
http://localhost/project/products/default.aspx to get it working.

As second, you page is under "/project" and the config key refer to
"/"

<add key="/Default.aspx?id=4" value="/products/default.aspx" />
Mar 12 '07 #8

P: n/a
On Mar 12, 10:41 am, "Milsnips" <milsn...@hotmail.comwrote:
Hi Alexey,

Thanks for the info, yes i understand what you mean however this is what i
am trying to achieve..

Sorry, but...

you have the following in the config

<add key="/Default.aspx?id=4" value="/products/default.aspx" />

It means you should call /products/default.aspx to rewrite from /
Default.aspx?id=4

Please check the original example at http://www.15seconds.com/issue/030522.htm

Mar 12 '07 #9

P: n/a
Hi Alexey,

yes you are right! i misunderstood it and was doing the key/value the wrong
way around that is why i was getting the problem.
I understand it now well. thanks again for your time and help.

regards,
Paul

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
On Mar 12, 10:41 am, "Milsnips" <milsn...@hotmail.comwrote:
>Hi Alexey,

Thanks for the info, yes i understand what you mean however this is what
i
am trying to achieve..


Sorry, but...

you have the following in the config

<add key="/Default.aspx?id=4" value="/products/default.aspx" />

It means you should call /products/default.aspx to rewrite from /
Default.aspx?id=4

Please check the original example at
http://www.15seconds.com/issue/030522.htm

Mar 13 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.