What are the event handlers that we can have in Global.asax file?

Application Events: Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache Session Events: Session_Start,Session_End In ASP.NET, the Global.asax file is used to handle application-level events and is often referred to as the “Global Application Class.” It allows you to respond to application-level events such as application start, end, … Read more

What is the good practice to implement validations in aspx page?

Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources. In ASP.NET, implementing validations in an ASPX page can be achieved using various techniques and controls provided by the framework. Here are some good practices for implementing validations: Use Validation Controls: ASP.NET provides … Read more

How can we prevent browser from caching an ASPX page?

We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property: Response.Cache.SetNoStore (); Response.Write (DateTime.Now.ToLongTimeString ()); To prevent a browser from caching an ASPX page in ASP.NET, you can utilize various methods. Here are a few common approaches: Setting Cache Control Headers: You can set cache control headers in the response to instruct … Read more

Write code to send e-mail from an ASP.NET application?

MailMessage mailMess = new MailMessage (); mailMess.From = “abc@gmail.com”; mailMess.To = “xyz@gmail.com”; mailMess.Subject = “Test email”; mailMess.Body = “Hi This is a test mail.”; SmtpMail.SmtpServer = “localhost”; SmtpMail.Send (mailMess); MailMessage and SmtpMail are classes defined System.Web.Mail namespace. To send an email from an ASP.NET application, you can use the SmtpClient class available in the System.Net.Mail … Read more

What is Protected Configuration?

It is a feature used to secure connection string information. Protected Configuration in ASP.NET refers to a mechanism provided by the .NET Framework for securing sensitive information, such as connection strings, application settings, and other configuration data within configuration files (typically the web.config file). This feature aims to prevent unauthorized access to critical information by … Read more