I recently started learning about HttpModules and made my first one. I was wondering if someone could explain why some modules in the the web.config include a lot of extra info and others do not.
public class LowerCaseRequest : IHttpModule { public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(this.OnBeginRequest);
[Code]....
It works grate on my PC running XP and IIS 5.1
but on my webserver running IIS7 and WS 2008 dosn't works.
I attempted to find any information in regards to best practices of handling errors inside of a HttpModule unfortunately I can't seem to find any information on Google in regards to this.
All the information I've found all pertains in how to use the global.asax or a custom http module to log errors which is completely not pertinent.
Edit: Clearly this question has been misunderstood. I am seeking information regarding software patterns that are employed to prevent a HttpModules from faulting, triggering custom errors redirection, and faulting again causing infinite exception chains until IIS shuts down the thread entirely.
This however is very nontrivial since the HttpSessionState collection can't be depended on for the life cycle of HttpModules. Since error conditions have already occurred it would be improper to expect that I could read the ASP.NET session cookie to get an identifier that I could store user specific data in the application cache. Storing data in the HttpRequest.Items collection would be pointless since that in no way exists across multiple requests.
I have an AJAX service where I'm pulling HTML content. I want to Response.Write() it to the browser as a string. I can't figure out how to do it so it remains a string like this rather than formatting the HTML:
I have this string test = HttpUtility.HtmlDecode("http://test.com/Folder1/Folder2/my%20view.aspx");When I look into test it still has %20 instead of a space. Why is it not decoding this?
I have vendors who are passing customers to us via an encoded URL. The problem is that Request.QueryString["FieldName"] is returning NULL on some of them and I can't fiqure out why?
For Example, one vendor is sending : http://.....ViewListing.aspx%3FListingID%3D1187721%26Source%3D6"] which returns a NULL value when Request.QueryString["ListingID"] is used.
Using Server.UrlDecode(Request.RawUrl.ToString()), however, will decode itpProperly as /ViewListing.aspx?ListingID=1187721&Source=6
How do I get the Request object to properly retrieve the values?
I would like to make sure that everything that goes into my database is safe, i.e. protection from sql injection.
What I want to do is type something in a textbox, "<b>hello</b>" for example, it be encoded before it's put in the database, but when I retrieve it, I want it to display "hello" in bold.
I've tried the obvious of server.encode on input and server.decode on the output (to a label and a literal control), but couldn't get it to display the text in bold without having unencoded text in the database.
Uri uri = new Uri(redirectionUrl); NameValueCollection col = HttpUtility.ParseQueryString(uri.Query)
uri.Query is already decoded - so is there any way I can prevent ParseQueryString decoding it again?Apart from that - is there another method to retrieve a name value collection from a Uri without modifying any components?
I need to encode querystring from the aspx itself, like we do <%Eval()%>.Below is my html
<asp:HyperLinkField HeaderText="Your Header" DataNavigateUrlFields="userId" DataTextField="Your Data Field to Display" HeaderStyle-HorizontalAlign="Center" DataNavigateUrlFormatString="mypage.aspx?type=2&userId={0}" ItemStyle-Width="35%" ItemStyle-HorizontalAlign="Left" />
Here i want to encrypt or simply encode the parameters type and userid so that it will look like encrypted.
I am trying to set up a POST from one aspx file to another progromatically. Inside the POST is a String of XML data which i have properly added to Server.HtmlEncode(). For some reason, when I grab it in my logs on the other page, it is showing with 3 question marks. I at first thought it was logging text i left somewhere, but have narrowed it down to a Encoding error of some sort because when i change the encoding it changes the character, and when I just put some text in there, i see it on the other side fine. i have tried UTF 8,UTF32,Unicode,ASCII... Can't seem to find the right combination. Can't find the UTF-16 when I use the Encoding object
Below is my Code:
[Code]....My Sending Debug log has the Extension xml coming out in HTML format correctly before POST. Below is just a piece of it[Code]....
I just installed VS2010 and opened the root machine.config and web.config files for review and I found some errors. In machine.config, the following line has errors in both entries for <Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior>. When I hover the cursor over them I get a tooltip text which displays: "The element 'endpointBehaviors' has invalid child element 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior'. List of possible elements expected: '...(list of options here)...'. The same problem happens for the second appereance in tag <serviceBehaviors>.
[Code]....
In web.config, there is a tag called <protocols> that has an error with a tooltip text that says "The element 'system.web' has invalid child element 'protocols'. List of possible elements expected: '...(list of options here)...'.
Currently, I work on an ASP.NET project which is hosted under version control and is used on several developer machines, tester machine and production environment.
In three cases, configuration (Web.config) may be different. For example, developer and tester environments use testing SQL Server, whereas in production environment, another SQL Server is accessed, so the connection string is different in those cases.
We want to keep three versions of Web.config in subversion. But modifying each of three files every time we need to add, remove or change a common setting is annoying: it would be nice to have a common, master Web.config, which will be inherited by each of the three Web.config files.
How to set up an ASP.NET project which will use a master configuration file and different slave configuration files on different machines, thus sharing the same project/source code/configuration files in subversion?
When I open my ASP.NET site in IIS and try to open the .NET Trust Levels, I get an error message:
.NET Trust Levels There was an error while performing this operation.
Details: Filename: ?C:inetpubwwwrootmyappweb.config Line number: 445
Error: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"),or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
I've checked a few places, but I haven't found anything that seems like it would be locking that setting. Is there a systematic way of determining where that setting is locked?
We are experiencing some strange behaviour on one of our ASP.NET web servers (Windows 2003 64-bit). After some activity, two third-party controls are unable to run correctly. One is log4net (it does not write error messages out) and the other is a menu control (it displays eval message instead of picking up its license). The one common thread is that both controls pick up their config from external config files (linked to from web.config).
Just wondering if anyone has any thoughts on this or experienced this in any way. Is it related to file/folder rights? The server has been running fine for a while and just started exhibiting this behaviour. Perhaps it occurs around the time the worker processes are recycled.
I am running into a problem with a web.config in a child project that has the same connection string setting as a parent. We have this in several of our web apps but there is one case where we want a child not to use the parent web.config. Is there a setting or command in the child web.config to ignore the parent web.config?
in MyWeb there are all the aspx page and some entites datamodel, in MyApp there are the class with function like "getter data from DB" and there is a entity data model.
afeter the deploy, I have only the web.config and the connection string for the entity datamodel....itīs run ok, read/write the data on the DB.
The problem is with MyApp.....after the deploy it is a dll file and I donīt have the app.config and the entity inside it donīt run, not read/write nothing on the DB.
There arenīt error or messager but not read/write the data in the MyApp project.
all run on the iis 7
now...the question is:
I lose the connection string (in app.config) after the deploy?
Can I put a entity in the MyWeb and read it in another project (myApp)?