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

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

Where can i place this line of code so that its accessible thruout my entire web application?

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

Currently im capturing the users name during certain functions, so at the moment, i have the line below within each event that i need that information. Instead of having that line everywhere, cant iplace that line in a class or something so that i can just access it by "usn" string usn = User.Identity.Name.ToString();

View Complete Post

More Related Resource Links

New off line application working with sdf file. Need advice


Hey Folks

I am working on a project currently where I need to get data out of a 3rd party vendor's software that uses a .sdf file I looked this up and its a SQL CE file. I was hoping to just link to with with access but thats apparently not going to happen. I need to link to the database extract data from it to a csv file for later use. I also and most important I need to get the data from it and create a report that can be printed while on a customers site that my or may not have web access so I need for this program to be on and off line. I had my webapplication that I have been working on open and was able to bring up the sdf file under the server exploere however I can't seem to get anything out of it when I try to do grid views or detail views errors out.

Can I use one of Visual Studio projects to create this sort of applicaiton if so what would be the best approach. I would love to get an access odbc driver since office is allready installed on the employee's laptop's



Ho to fire the Application Error in asax from the code?


 Hi All,

I have this code in Global.asax but it not firing once an error occured:


void Application_Error(object sender, EventArgs e)



        // Get the error details

        HttpException lastErrorWrapper = Server.GetLastError() as HttpException;

        Exception lastError = lastErrorWrapper;

        if (lastErrorWrapper.InnerException != null)

        lastError = lastErrorWrapper.InnerException;



        string lastErrorTypeName = lastError.GetType().ToString();

        string lastErrorMessage = lastError.Message;

        string lastErrorStackTrace = lastError.StackTrace;



Please help me so I can call this method from any page?

Thaxxxxxxxxxxxxx a lot,



Code Reviews: Find and Fix Vulnerabilities Before Your Application Ships


Code defects can be found using many approaches, but manual code reviews stand out in terms of precision and quality. We provide some best practices for planning and executing code reviews on your own team.

M. Chmielewski, N. Clift, S. Fonrobert, and T. Ostwald

MSDN Magazine November 2007

Testing: Perform Code Coverage Analysis with .NET to Ensure Thorough Application Testing


When running your tests how do you know which parts of your product code are actually executed and tested? This article presents a complete system called Fundamental Function code coverage that operates at the method level. The author gives an overview of the system so you can understand code coverage principles, explains the key parts of the underlying code, and discusses how code coverage fits into the overall product development cycle. After reading this article you will be able to perform code coverage analysis on any .NET software system.

James McCaffrey

MSDN Magazine April 2004

C# and the Web: Writing a Web Client Application with Managed Code in the Microsoft .NET Framework


When the author wanted to build a middleware Web client to connect to other applications over the Internet, he realized that the XMLHttpRequest COM object was not sufficient for his purposes. In order to build a Web client using managed code, the author had to use the HTTPWebRequest and HTTPWebResponse classes provided by the Microsoft .NET framework. These classes are used in the sample project as a substitute for the less powerful XMLHttpRequest COM object, allowing the author to build a full-featured Web client. They also take advantage of all the benefits that the CLR and managed code have to offer.

Avi Ben-Menahem

MSDN Magazine September 2001

Whats wrong with this code, im getting blue line under the createStatus next the switch

Error message: Use of unassigned local variable 'createStatus'
            MembershipCreateStatus createStatus;
            MembershipUser newUser = Membership.CreateUser(Username.Text, Password.Text, Email.Text);

            switch (createStatus)
                case MembershipCreateStatus.Success:
                    this.CreateAccountResults.Text = "The user account was successfully created!";
                case MembershipCreateStatus.DuplicateUserName:
                    this.CreateAccountResults.Text = "There already exists a user with this username.";
                case MembershipCreateStatus.DuplicateEmail:
                    this.CreateAccountResults.Text = "There already exists a user with this email address.";
                case MembershipCreateStatus.InvalidEmail:
                    this.CreateAccountResults.Text = "There email address you provided in invalid.";
                case MembershipCreateStatus.InvalidPassword:
                    this.CreateAccountResults.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-a

Resume SharePoint Services Web Application and returns code 1387 error


Hello everyone! Newbie here. I would like to ask how to start the SharePoint Services Web Application on (WSS3.0,internal database, stanalone users) without getting error 1387 ?

I would love to provide more information regarding this issue but what I got is error 1387 displayed in the browser.

I look forward to seeing you guys feedback from your expertise angle.



.net 3.5 in conjunction with CRM 4.0 email router adding code to subject line of emails causing spam

We use CRM 4.0, which is using .net framework 3.5 SP 1.  Emails sent out of CRM go through and email router and the subject line of these emails is getting "=?us-ascii?Q? added to the beginning of the subject line and "?= added to the end of the subject line. This is causing a large amount of our emails getting spammed. I was told by the CRM support that this is an issue with .net 3.5 and won't be fixed until .net 4.0, which CRM won't support for another year.  Is there not a .net 3.5 patch that can address this?

Can someone please explain what this line of code is actually doing

I took this line of control from this post http://forums.asp.net/t/1201593.aspx I'm actually trying to do the same dynamic accordion.   MyAccordion.ItemDataBound += new EventHandler<AccordionItemEventArgs>(MyAccordion_ItemDataBound);    I converted to vb.net and this is the equivalent. MyAccordion.ItemDataBound += New EventHandler(Of AccordionItemEventArgs)(MyAccordion_ItemDataBound) when I type  that line in my code I get an error.. Error 3 'Public Event ItemDataBound(sender As Object, e As AjaxControlToolkit.AccordionItemEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.    and   Error 4 Delegate 'System.EventHandler(Of AjaxControlToolkit.AccordionItemEventArgs)' requires an 'AddressOf' expression or lambda  

How to Find out Windows service application path from Code ?

Dear frnds, Could you please help me to find out the path of  windows serivce exe ( application path ) from code?   Regards. Sajid P K  

The Best Place to store Settings for Web Application.

I want to create an Application Setting or Control Value for "Application Run Mode", which will indicate if the application is in Testing Mode or Live Mode. So I have created this Enum Type: Public Enum AppRunModeType Live Testing End Enum and, this will be used inside the the Web Application to determine if the application run mode, and hide/show some UI Controls accordingly. This Setting "Application Run Mode" is not a User Setting, it is a setting to be controlled by the developer who is deploying the application. Where is the best place to store this value ? I am thinking there are 2 places: 1. In web.config "appSettings" secting, 2. Or in Project Properties Page/Settings Section. If I choose to store it in web.config, then, I will not be able to have Strong Type Access to the value like the Enum type, and I have to convert from Enum Type to String and vise versa. If I choose to store it in Project Properties Page/Settings Section, then I cannot do that, becuase my Web Application is not a Porject and I cannot find this page there, or I will have to convert the Web Application to a Web Application Porject, and this is a Long Story. Also, How I can access My.Settings object from the Web Application ? Appreciate if some one could point me to the right direction and the best way to hanlde such requirement.

code to run visual basic application in between desktop icon and wallpaper

Plex can anyone of you tell me the visual basic net code to make the application run between desktop icon and background wallpaper . it mean if that application is running in background the icon in the desktop should be selectable...  pleax send you code to me ....    

How do I obfuscate .Net IL code using command line program?

How do I obfuscate .Net IL code using command line program? I want free tool that can be deployed to obfuscate DLL generated from compiled tool?

set the proerty from code behind line chart wpf

< Style x:Key = " InvisibleDataPointStyle " TargetType = " c:LineDataPoint " > < Setter Property = " Opacity " Value = " 0 " /> < Setter Property = " Background " Value = " Yellow " /> </ Style >

Need vb.net equivalent of this line of c# code....

I have a line of c# that I'm looking to convert into vb.  It looks like the following:return GetFromSession("CurrentUser") as Account; "GetFromSession" is a method which returns an object. Here's the code for that method if it helps:private static object GetFromSession(string key) { if (HttpContext.Current == null || HttpContext.Current.Session == null) { return null; } return HttpContext.Current.Session[key]; } My problem is the "as Account" part of my one line of c# code needs to be converted into vb but I'm not sure of the equivalent. Currently, my vb.net won't allow it. Any idea what I should use here? Thanks  

Can I add an entire folder to my Web Application Project?

Hi gang, I have been developing my first ASP.Net 2.0 website using the Web Application Project model. I ran into a funny problem and I wanted to bounce it off you guys. I started working with a component called FCKeditor that is an HTML javascript editor. In addition to a .DLL file, you have to add an entire folder of stuff including javascript, CSS, and images. I tried copying the folder as a subfolder under the project root and then tried Add / Existing Item to add the folder to my project, but you can't add folders, only individual files. Am I missing something? Is there a way to add an entire folder of content to my Web Application Project? Thanks,Kevin

Help me modify regex code, only one line.

I have this code Dim parts As New List(Of String)(Regex.Split(RichTextBox2.Text, "~\d")) That splits lines in this format into parts: ~1Hello~2~3Bye~4~5Morning~6 So if I do MsgBox(parts(5)), it will show me "Morning". ------------------------------------------------------------------------ I want to do the exact same thing, but now my my line is arranged like this: Hello, Bye, Morning,   
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