- How do you implement postback with a text box? What is postback and usestate?
Make AutoPostBack property to true
- How can you debug an ASP page, without touching the code?
- What is SQL injection?
An SQL injection attack "injects" or manipulates SQL code by adding unexpected SQL to a query.
Many web pages take parameters from web user, and make SQL query to the database. Take for instance when a user login, web page that user name and password and make SQL query to the database to check if a user has valid name and password.
Username: ' or 1=1 ---
This would execute the following query against the users table:
select count(*) from users where userName='' or 1=1 --' and userPass=''
- How can u handle Exceptions in Asp.Net?
- How can u handle Un Managed Code Exceptions in ASP.Net?
- Asp.net - How to find last error which occurred?
LastError = Server.GetLastError();
if (LastError != null)
ErrMessage = LastError.Message;
ErrMessage = "No Errors";
Response.Write("Last Error = " + ErrMessage);
7. How to do Caching in ASP?
A: <%@ OutputCache Duration="60" VaryByParam="None" %>
One version of page cached (only raw GET)
n versions of page cached based on query string and/or POST body
n versions of page cached based on value of v1 variable in query string or POST body
n versions of page cached based on value of v1 and v2 variables in query string or POST body
<%@ OutputCache Duration="60" VaryByParam="none" %>
<%@ OutputCache Duration="60" VaryByParam="*" %>
<%@ OutputCache Duration="60" VaryByParam="name;age" %>
The OutputCache directive supports several other cache varying options
- VaryByHeader - maintain separate cache entry for header string changes (UserAgent, UserLanguage, etc.)
- VaryByControl - for user controls, maintain separate cache entry for properties of a user control
- VaryByCustom - can specify separate cache entries for browser types and version or provide a custom GetVaryByCustomString method in HttpApplicationderived class
- Any alternative to avoid name collisions other then Namespaces.
A scenario that two namespaces named N1 and N2 are there both having the same class say A. now in another class i ve written
using N1;using N2;
and i am instantiating class A in this class. Then how will u avoid name collisions?
Ans: using alias
Eg: using MyAlias = MyCompany.Proj.Nested;
- Which is the namespace used to write error message in event Log File?
- What are the page level transaction and class level transaction?
- What are different transaction options?
- What is the namespace for encryption?
- What is the difference between application and cache variables?
- What is the difference between control and component?
- You ve defined one page_load event in aspx page and same page_load event in code behind how will prog run?
- Where would you use an IHttpModule, and what are the limitations of any approach you might take in implementing one?
- Can you edit data in the Repeater control? Which template must you provide, in order to display data in a Repeater control? How can you provide an alternating color scheme in a Repeater control? What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
- What is the use of web.config? Difference between machine.config and Web.config?
ASP.NET configuration files are XML-based text files--each named web.config--that can appear in any directory on an ASP.NET Web application server. Each web.config file applies configuration settings to the directory it is located in and to all virtual child directories beneath it. Settings in child directories can optionally override or modify settings specified in parent directories. The root configuration file--WinNT\Microsoft.NET\Framework\
\config\machine.config—provides default configuration settings for the entire machine. ASP.NET configures IIS to prevent direct browser access to web.config
files to ensure that their values cannot become public (attempts to access them will cause ASP.NET to return 403: Access Forbidden).
At run time ASP.NET uses these web.config configuration files to hierarchically compute a unique collection of settings for each incoming URL target request (these settings are calculated only once and then cached across subsequent requests; ASP.NET automatically watches for file changes and will invalidate the cache if any of the configuration files change).
What is the use of sessionstate tag in the web.config file?
Configuring session state: Session state features can be configured via the