Sunday, November 24, 2013

Install Skype on Ubuntu 12.04 LTS 64-bit

For 32Bit
Terminal Commands:
wget  http://download.skype.com/linux/skype-ubuntu-lucid_4.2.0.11-1_i386.deb
sudo dpkg -i skype-ubuntu-lucid_4.2.0.11-1_i386.deb
sudo apt-get -f install;rm skype-ubuntu-lucid_4.2.0.11-1_i386.deb
 
For 64Bit Terminal Commands:
sudo dpkg --add-architecture i386
sudo apt-get install ia32-libs
sudo apt-get update
wget http://download.skype.com/linux/skype-ubuntu-lucid_4.2.0.11-1_i386.deb
sudo dpkg -i skype-ubuntu-lucid_4.2.0.11-1_i386.deb
sudo apt-get -f install;rm skype-ubuntu-lucid_4.2.0.11-1_i386.deb
After all of this run in terminal sudo apt-get install sni-qt:i386; This will restore the skype contact window
That's all, work done in maximum 5 minutes. I use Ubuntu on 64bit and this method to install Skype worked always perfectly.

Friday, September 13, 2013

How to remove unused usings from class file ?

When we create a .cs file means code file class is automatically create. That .cs file means class has default usings for namespace.


using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;

We don't use all namespaces  in that class so we have to remove unused namespaces from file. We can remove  namespace manually but it takes time and need full knowledge of class library so we can use Visual Studio .

Step 1:  Right Click in .cs File.
Step 2:  Move on Organize usings.
Step 3: Click on Remove Unused Usings.

After that we have only those namespaces in the file these are using.
 

Wednesday, September 11, 2013

Programatically create a table using c#

Table tbl = new Table();
        tbl.ID = "table1";

        this.Controls.Add(tbl);

        for (int row = 0; row < 5; row++)
        {
            TableRow rw = new TableRow();


            TableCell cell = new TableCell();

            Label text = new Label();
            text.Text = "text";

            cell.Controls.Add(text);
            rw.Cells.Add(cell);

            tbl.Controls.Add(rw);

        }

Monday, September 9, 2013

IIS 7.0 informational HTTP status codes

1xx - Informational
These HTTP status codes indicate a provisional response. The client computer receives one or more 1xx responses before the client computer receives a regular response.

IIS 7.0 uses the following informational HTTP status codes:
100 - Continue.
101 - Switching protocols.

2xx - Success
These HTTP status codes indicate that the server successfully accepted the request.

IIS 7.0 uses the following success HTTP status codes:
200 - OK. The client request has succeeded.
201 - Created.
202 - Accepted.
203 - Nonauthoritative information.
204 - No content.
205 - Reset content.
206 - Partial content.

3xx - Redirection
These HTTP status codes indicate that the client browser must take more action to fulfill the request. For example, the client browser may have to request a different page on the server. Or, the client browser may have to repeat the request by using a proxy server.

IIS 7.0 uses the following redirection HTTP status codes:
301 - Moved permanently.
302 - Object moved.
304 - Not modified.
307 - Temporary redirect.

4xx - Client error
These HTTP status codes indicate that an error occurred and that the client browser appears to be at fault. For example, the client browser may have requested a page that does not exist. Or, the client browser may not have provided valid authentication information.

IIS 7.0 uses the following client error HTTP status codes:
400 - Bad request. The request could not be understood by the server due to malformed syntax. The client should not repeat the request without modifications.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 400 error:
400.1 - Invalid Destination Header.
400.2 - Invalid Depth Header.
400.3 - Invalid If Header.
400.4 - Invalid Overwrite Header.
400.5 - Invalid Translate Header.
400.6 - Invalid Request Body.
400.7 - Invalid Content Length.
400.8 - Invalid Timeout.
400.9 - Invalid Lock Token.
401 - Access denied.

IIS 7.0 defines several HTTP status codes that indicate a more specific cause of a 401 error. The following specific HTTP status codes are displayed in the client browser but are not displayed in the IIS log:
401.1 - Logon failed.
401.2 - Logon failed due to server configuration.
401.3 - Unauthorized due to ACL on resource.
401.4 - Authorization failed by filter.
401.5 - Authorization failed by ISAPI/CGI application.
403 - Forbidden.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 403 error:
403.1 - Execute access forbidden.
403.2 - Read access forbidden.
403.3 - Write access forbidden.
403.4 - SSL required.
403.5 - SSL 128 required.
403.6 - IP address rejected.
403.7 - Client certificate required.
403.8 - Site access denied.
403.9 - Forbidden: Too many clients are trying to connect to the Web server.
403.10 - Forbidden: Web server is configured to deny Execute access.
403.11 - Forbidden: Password has been changed.
403.12 - Mapper denied access.
403.13 - Client certificate revoked.
403.14 - Directory listing denied.
403.15 - Forbidden: Client access licenses have exceeded limits on the Web server.
403.16 - Client certificate is untrusted or invalid.
403.17 - Client certificate has expired or is not yet valid.
403.18 - Cannot execute requested URL in the current application pool.
403.19 - Cannot execute CGI applications for the client in this application pool.
403.20 - Forbidden: Passport logon failed.
403.21 - Forbidden: Source access denied.
403.22 - Forbidden: Infinite depth is denied.
404 - Not found.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 404 error:
404.0 - Not found.
404.1 - Site Not Found.
404.2 - ISAPI or CGI restriction.
404.3 - MIME type restriction.
404.4 - No handler configured.
404.5 - Denied by request filtering configuration.
404.6 - Verb denied.
404.7 - File extension denied.
404.8 - Hidden namespace.
404.9 - File attribute hidden.
404.10 - Request header too long.
404.11 - Request contains double escape sequence.
404.12 - Request contains high-bit characters.
404.13 - Content length too large.
404.14 - Request URL too long.
404.15 - Query string too long.
404.16 - DAV request sent to the static file handler.
404.17 - Dynamic content mapped to the static file handler via a wildcard MIME mapping.
404.18 - Querystring sequence denied.
404.19 - Denied by filtering rule.
405 - Method Not Allowed.
406 - Client browser does not accept the MIME type of the requested page.
408 - Request timed out.
412 - Precondition failed.
5xx - Server error
These HTTP status codes indicate that the server cannot complete the request because the server encounters an error.

IIS 7.0 uses the following server error HTTP status codes:
500 - Internal server error.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 500 error:
500.0 - Module or ISAPI error occurred.
500.11 - Application is shutting down on the Web server.
500.12 - Application is busy restarting on the Web server.
500.13 - Web server is too busy.
500.15 - Direct requests for Global.asax are not allowed.
500.19 - Configuration data is invalid.
500.21 - Module not recognized.
500.22 - An ASP.NET httpModules configuration does not apply in Managed Pipeline mode.
500.23 - An ASP.NET httpHandlers configuration does not apply in Managed Pipeline mode.
500.24 - An ASP.NET impersonation configuration does not apply in Managed Pipeline mode.
500.50 - A rewrite error occurred during RQ_BEGIN_REQUEST notification handling. A configuration or inbound rule execution error occurred.
Note Here is where the distributed rules configuration is read for both inbound and outbound rules.
500.51 - A rewrite error occurred during GL_PRE_BEGIN_REQUEST notification handling. A global configuration or global rule execution error occurred.
Note Here is where the global rules configuration is read.
500.52 - A rewrite error occurred during RQ_SEND_RESPONSE notification handling. An outbound rule execution occurred.
500.53 - A rewrite error occurred during RQ_RELEASE_REQUEST_STATE notification handling. An outbound rule execution error occurred. The rule is configured to be executed before the output user cache gets updated.
500.100 - Internal ASP error.
501 - Header values specify a configuration that is not implemented.
502 - Web server received an invalid response while acting as a gateway or proxy.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 502 error:
502.1 - CGI application timeout.
502.2 - Bad gateway.
503 - Service unavailable.

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 503 error:
503.0 - Application pool unavailable.
503.2 - Concurrent request limit exceeded.

Wednesday, August 21, 2013

Amulyam.in

You can win free mobile recharge with playing games and contests through Amulyam. Go with this link and sign up with amulyam. Amulyam.in

Wednesday, July 10, 2013

Top 50 ASP.Net Interview Questions & Answers

1. What is ASP.Net?
It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, xml etc.

2. What’s the use of Response.Output.Write()? We can write formatted output  using Response.Output.Write().

3. In which event of page cycle is the ViewState available?   After the Init() and before the Page_Load().

4. What is the difference between Server.Transfer and Response.Redirect?  
In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser.  This provides a faster response with a little less overhead on the server.  The clients url history list or current url Server does not update in case of Server.Transfer.
Response.Redirect is used to redirect the user’s browser to another page or site.  It performs trip back to the client where the client’s browser is redirected to the new page.  The user’s browser history list is updated to reflect the new address.

5. From which base class all Web Forms are inherited?
Page class. 

6. What are the different validators in ASP.NET?
  1. Required field Validator
  2. Range  Validator
  3. Compare Validator
  4. Custom Validator
  5. Regular expression Validator
  6. Summary Validator
7. Which validator control you use if you need to make sure the values in two different controls matched?
Compare Validator control.

8. What is ViewState?
ViewState is used to retain the state of server-side objects between page post backs.

9. Where the viewstate is stored after the page postback?
ViewState is stored in a hidden field on the page at client side.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

10. How long the items in ViewState exists?
They exist for the life of the current page.

11. What are the different Session state management options available in ASP.NET?
  1. In-Process
  2. Out-of-Process.
In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external server.  The external server may be either a SQL Server or a State Server.  All objects stored in session are required to be serializable for Out-of-Process state management.

12. How you can add an event handler?
 Using the Attributes property of server side control.
e.g.
[csharp]
btnSubmit.Attributes.Add(“onMouseOver”,”JavascriptCode();”)
[/csharp]

13. What is caching?
Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.

14. What are the different types of caching?
ASP.NET has 3 kinds of caching :
  1. Output Caching,
  2. Fragment Caching,
  3. Data Caching.
15. Which type if caching will be used if we want to cache the portion of a page instead of whole page?
Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:
[xml]
<%@ OutputCache Duration=”120″ VaryByParam=”CategoryID;SelectedID”%>
[/xml]

16. List the events in page life cycle.
  1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8)Render

17. Can we have a web application running without web.Config file?
  Yes

18. Is it possible to create web application with both webforms and mvc?
Yes. We have to include below mvc assembly references in the web forms application to create hybrid application.
[csharp]
System.Web.Mvc
System.Web.Razor
System.ComponentModel.DataAnnotations
[/csharp]

19Can we add code files of different languages in App_Code folder?
  No. The code files must be in same language to be kept in App_code folder.

20. What is Protected Configuration?
It is a feature used to secure connection string information.

21. Write code to send e-mail from an ASP.NET application?
[csharp]
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);
[/csharp]
MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

 22. How can we prevent browser from caching an ASPX page?
  We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:
[csharp]
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
[/csharp]

23. 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.

24. 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

25. Which protocol is used to call a Web service?
HTTP Protocol

26. Can we have multiple web config files for an asp.net application?
Yes.

27. What is the difference between web config and machine config?
Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.

28.  Explain role based security ?
  Role Based Security used to implement security based on roles assigned to user groups in the organization.
Then we can allow or deny users based on their role in the organization. Windows defines several built-in groups, including Administrators, Users, and Guests.
[xml]
<AUTHORIZATION>< authorization >
< allow roles=”Domain_Name\Administrators” / >   < !– Allow Administrators in domain. — >
< deny users=”*”  / >                            < !– Deny anyone else. — >
< /authorization >
[/xml]

29. What is Cross Page Posting?
When we click submit button on a web page, the page post the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of  the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

30. How can we apply Themes to an asp.net application?
We can specify the theme in web.config file. Below is the code example to apply theme:
[xml]
<configuration>
<system.web>
<pages theme=”Windows7″ />
</system.web>
</configuration>
[/xml]

31: What is RedirectPermanent in ASP.Net?
  RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.

32: What is MVC?
MVC is a framework used to create web applications. The web application base builds on  Model-View-Controller pattern which separates the application logic from UI, and the input and events from the user will be controlled by the Controller.

33. Explain the working of passport authentication.
First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page

34. What are the advantages of Passport authentication?
All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.
Users can maintain his/ her information in a single location.

35. What are the asp.net Security Controls?
  • <asp:Login>: Provides a standard login capability that allows the users to enter their credentials
  • <asp:LoginName>: Allows you to display the name of the logged-in user
  • <asp:LoginStatus>: Displays whether the user is authenticated or not
  • <asp:LoginView>: Provides various login views depending on the selected template
  • <asp:PasswordRecovery>:  email the users their lost password
36: How do you register JavaScript for webcontrols ?
We can register javascript for controls using <CONTROL -name>Attribtues.Add(scriptname,scripttext) method.

37. In which event are the controls fully loaded?
Page load event.

38: what is boxing and unboxing?
Boxing is assigning a value type to reference type variable.
Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable.

39. Differentiate strong typing and weak typing
In strong typing, the data types of variable are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arises at runtime.

40. How we can force all the validation controls to run?
The Page.Validate() method is used to force all the validation controls to run and to perform validation.

41. List all templates of the Repeater control.
  • ItemTemplate
  • AlternatingltemTemplate
  • SeparatorTemplate
  • HeaderTemplate
  • FooterTemplate
42. List the major built-in objects in ASP.NET? 
  • Application
  • Request
  • Response
  • Server
  • Session
  • Context
  • Trace
43. What is the appSettings Section in the web.config file?
The appSettings block in web config file sets the user-defined values for the whole application.
For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:
[csharp]
<em><configuration>
<appSettings>
<add key=”ConnectionString” value=”server=local; pwd=password; database=default” />
</appSettings></em>
[/csharp]

44.      Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.

45. What is the difference between an HtmlInputCheckBox control and anHtmlInputRadioButton control?
In HtmlInputCheckBoxcontrol, multiple item selection is possible whereas in HtmlInputRadioButton controls, we can select only single item from the group of items.

46. Which namespaces are necessary to create a localized application?
System.Globalization
System.Resources

47. What are the different types of cookies in ASP.NET?
Session Cookie – Resides on the client machine for a single session until the user does not log out.
Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.

48. What is the file extension of web service?
Web services have file extension .asmx..

49. What are the components of ADO.NET?
The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.

50. What is the difference between ExecuteScalar and ExecuteNonQuery?
ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.

Wednesday, April 10, 2013

How to create Captcha in ASP.NET

1. Create one page with name "Captcha.aspx"

2. No any control require in this page
3. Go to Captcha.aspx.vb write the below code

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'create object of Bitmap Class and set its width and height.
        Dim objBMP As Bitmap = New Bitmap(180, 51)
        'Create Graphics object and assign bitmap object to graphics' object.
        Dim objGraphics As Graphics = Graphics.FromImage(objBMP)
        objGraphics.Clear(Color.White)
        objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias
        Dim objFont As Font = New Font("arial", 30, FontStyle.Bold)
        'genetating random 6 digit random number
        Dim randomStr As String = GeneratePassword()
        'set this random number in session
        Session.Add("randomStr", randomStr)
        Session.Add("randomStrCountry", randomStr)
        objGraphics.DrawString(randomStr, objFont, Brushes.Black, 2, 2)
        Response.ContentType = "image/GIF"
        objBMP.Save(Response.OutputStream, ImageFormat.Gif)
        objFont.Dispose()
        objGraphics.Dispose()
        objBMP.Dispose()
    End Sub
    Public Function GeneratePassword() As String
        ' Below code describes how to create random numbers.some of the digits and letters
        ' are ommited because they look same like "i","o","1","0","I","O".
        Dim allowedChars As String = "a,b,c,d,e,f,g,h,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,"
        allowedChars += "A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z,"
        allowedChars += "2,3,4,5,6,7,8,9"
        Dim sep() As Char = {","c}
        Dim arr() As String = allowedChars.Split(sep)
        Dim passwordString As String = ""
        Dim temp As String
        Dim rand As Random = New Random()
        Dim i As Integer
        For i = 0 To 5 - 1 Step i + 1
            temp = arr(rand.Next(0, arr.Length))
            passwordString += temp
        Next
        Return passwordString
    End Function


4. Use this page in you aspx page like this
//
 

                               
your textbox to insert code by user.

Thursday, April 4, 2013

How to delete duplicate records in sql without using temporary table

DELETE FROM table 
WHERE name IN (SELECT name FROM table GROUP BY name HAVING COUNT(*) > 1)
AND NOT id IN (SELECT min(id) FROM table GROUP BY name)

Monday, March 18, 2013

Wednesday, January 2, 2013

The connection was reset error in asp.net

Under system web in web.config
add this line..
system.web>
httpRuntime executionTimeout="999" maxRequestLength="2097151"/>