Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How to remove last 3 character from string in csharp?

Answer»

How to remove last 3 character from string in CSHARP?
Below is the code to remove last 3 character from string in C#.net

myString=myString.Substring(0,myString.LENGTH-3);


here in above code we can increase then length of removing character by length-3

2.

Give a example of Absolute Url, Relative Url, Application Root Relative Url?

Answer» GIVE a example of ABSOLUTE URL, Relative Url, Application Root Relative Url?
Below are the example which will LET you UNDERSTAND different example of above given URL with example
(1)Absolute Url


Absolute URL example
(2)Relative URL


relative URL example
(3)Application Root Relative Url


Application Toot Relative example
3.

what is Suspend and Resume in .NET Threading

Answer»

To understand this we take a example of MOVIE we can PAUSED and played it using our movie PLAYER similarly a thread ALSO may be paused by using Thread.Suspend method. And may be start again using the Thread.Resume method. Note that SLEEP method immediately forces the thread to sleep whereas the suspend method waits for the thread to be in a persistable position before pausing its activity.

4.

Change color of Label Forecolor through code in dotnet runtime?

Answer»

Change color of LABEL Forecolor through code in dotnet runtime?
Below is the code to change the Label Forecolor through code in asp.net

(1)Below is the first screen of HTML code of ASPX PAGE.


Label Color Change

(2)ASP.Net code of BUTTON click


Label Color Codebehind

5.

Prcoess to change port in WebSite WebApplication and WebService project in dotnet?

Answer»

Prcoess to change port in WebSite WebApplication and WebService project in dotnet?
(1)Below is the step to change the port in asp NET development server in webapplication project
(i)Right click on project on solution explorer and then select properties
(ii)Click on web Tab
(iiiCheck specific port instead of Auto assign Port

(2)Below is the step to change the port in asp net development server in WebSite/WebService project
(i)First right click on name of application in solution explorer
(ii)Now in property pane click down ERROR Use dynamic ports and select False from the dropdown LIST.
(iii)There is textbox beside port number there we can type port number in property pane.
(iv)Click outside of the Properties pane. This saves the property settings.

Note:- In some PLACES you have found something LIKE http://localhost:3450/Default.aspx here you can directly change port number in URl in properties of project

6.

Change the theme of Visual Studio dark or light?

Answer»

Change the theme of VISUAL STUDIO dark or light?
We can change the theme of visual studio by using below option
(1)Go to Tools MENUBAR
(2)Select options from tool menubar
(3)On options we will select Environment Tab
(4)In environment tab select General option
(5)Change the color theme from Color theme dropdownlist and press ok

7.

Void Function return value with out parameter

Answer»

protected void Page_Load(object SENDER, EVENTARGS e)
{
// Used as out PARAMETER
BOOL test1;
string test2;
int test3;
returnvalefromvoid("sdsdsd", out test1, out test2, out test3);
Response.Write(test1);
Response.Write(test2);
Response.Write(test3);
}


static void returnvalefromvoid(string value, out bool test1, out string test2, out int test3)
{
test1 = false;
test2 = "test";
test3 = 1;
// Assign value to all out PARAMETERS
}

8.

How to get System Directory,UserProfile,Machine Name in asp.net

Answer»

Below CODE is USED to GET location of system directory from asp.net code
System.Environment.SystemDirectory.ToString()

Below code is used to get MachineName from asp.net code
System.Environment.MachineName.ToString()

Below code is used to get USERPROFILE from asp.net code
Environment.GetEnvironmentVariable("USERPROFILE")

Below code is used to get ASP.NET is RUNNING as the account
Environment.UserName.ToString()


Below code is used to get TEMP environment variable
Environment.GetEnvironmentVariable("TEMP")

9.

Different Versions of .NET Frameworks

Answer»

Below are the different version of .net with there date of realses operating system version number FRAMEWORK info

Version Version Number RELEASE Date VISUAL STUDIO FrameworkOperating System
1.01.0.3705.0 13-02-2002Visual Studio .NETWindows Server 2003
1.11.1.4322.57324-04-2003Visual Studio .NET 2003Windows Server 2003
2.02.0.50727.42 07-11-2005 Visual Studio 2005 Windows Server 2003 R2
3.0 3.0.4506.30 06-11-2006 Visual Studio 2005 Windows VISTA, Windows Server 2008
3.5 3.5.21022.8 19-11-2007 Visual Studio 2008 Windows7 , Windows Server 2008 R2
4.0 4.0.30319.1 12-04-2010 Visual Studio 2010 Windows7 ,Windows Server 2008 R2
10.

Word Automatic Added In My URL in asp.net

Answer»

Some times some WORDS are automatically ADDED to url for EXAMPLE:-
http://localhost:1373/ProjectName/(S(h2gukh55vjbkbznzk3g1phao))/LoginDetails/Default.aspx

In above url (S(h2gukh55vjbkbznzk3g1phao))

To REMOVE this go to web.config and remove

cookieless="true"

Problem will resolve

11.

Syntax to add extra row above the GridView Header

Answer»

Below code will HELPS you to ADD one more header to the GridView

< ASP:GridView ID="gridviewid" runat="server" Caption="Here is the extra header above gridview header" >

12.

What is Substitution control in asp.net 4.0

Answer» SUBSTITUTION control is basicaly used for partial PAGE caching we can also used Substitution CONTROLS to SPECIFY the parts of the page that are exempt from caching.
13.

Colour coding in ListBox

Answer»

for (int i = 0; i < ListBox1.Items.Count; i++)
{
if(CONDITION)
{
ListBox1.Items[i].Attributes.CssStyle.Add("color", "GREEN");
}
else ((ds.Tables[0].Rows[i][3].ToString() == "1") & (ds.Tables[0].Rows[i][2].ToString() == "1"))
{
ListBox1.Items[i].Attributes.CssStyle.Add("color", "red");
}
}

14.

How passport authetication works and created

Answer»

When we apply Passport authentication to our application it will first checks the users machine for a latest/Current passport authentication cookie and if avail it will use that and If it is not available then ASP.NET directs the user to a Passport signon page.Then Passport SERVICE authenticates the user and then stores an authentication cookie on the users computer and direct the user to the REQUESTED page.
Some steps to use Passport authentication:-
1. First of all install the Passport SDK.
2. Second step to SET the APPLICATIONS authentication mode to Passport in Web.config.
3. Third step is to Set authorization to deny unauthenticated users.
4. Use the PassportAuthentication_OnAuthenticate event to access the users Passport profile to identify and authorize the user.
5. Implement a sign-out procedure to remove Passport cookies from the user s machine.

15.

Export gridview to PDF

Answer»

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using iTextSharp.text;
using iTextSharp.text.PDF;
using iTextSharp.text.html;
using System.IO;
using System.Collections;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
///Code to Bind GridView1 Here
}
protected void btnExport_Click(object sender, EventArgs e)
{
HtmlForm form = new HtmlForm();
//Below is control name to export to pdf
form.Controls.Add(GridView1);
StringWriter sw = new StringWriter();
HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);
form.Controls[0].RenderControl(hTextWriter);
string html = sw.ToString();
Document Doc = new Document();
//PdfWriter.GetInstance is CREATED
PdfWriter.GetInstance(Doc, new FILESTREAM(Environment.GetFolderPath
(Environment.SpecialFolder.Desktop)+ " getquestions.pdf", FileMode.Create));
Doc.Open();
Chunk c = new Chunk("Export GridView to PDF n",FontFactory.GetFont("Verdana", 15));
Paragraph p = new Paragraph();
p.Alignment = Element.ALIGN_CENTER;
p.Add(c);
Chunk chunk1 = new Chunk("By Getproductprice.com team n",FontFactory.GetFont("Verdana", 8));
Paragraph p1 = new Paragraph();
p1.Alignment = Element.ALIGN_RIGHT;
p1.Add(chunk1);
Doc.Add(p);
Doc.Add(p1);
System.Xml.XmlTextReader xmlReader =
new System.Xml.XmlTextReader(new StringReader(html));
HtmlParser.Parse(Doc, xmlReader);
Doc.Close();
string PATH = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+ " Pdffilepath.pdf";
ShowPdf(Path);
}
private void ShowPdf(string strS)
{
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition","attachment;filename=" + strS);
Response.TransmitFile(strS);
Response.End();
//Response.WriteFile(strS);
Response.Flush();
Response.Clear();
}
}

16.

Some facts about event in .NET

Answer»

(1)RETURN TYPE:-There is No return type of an event in .NET.
(2)Access Specifier:-Yes, THOUGH they are public by default.
(3)Shared Event:- Yes, but shared events MAY only be RAISED by shared methods.

17.

is it possible to have different Access modifier of Get and Set method

Answer»

No it is not possible to have different modifiers of a COMMON PROPERTY(GET and SET) which means that if the ACCESS modifier of a property get method is protected and it must be protected for the set method as well.

18.

Common navigation techniques in ASP.NET

Answer»

(1)Window.Open:- Its a script method which display a PAGE in a new browser window on the client.Syntax Is as Below
window.open( URL, name [ , features [, replace ] ] )
window.open('pagename.aspx','winname','left=0,top=0,width=500,height=500,toolbar=1,resizable=0');

(2)Hyperlink control:- Its function is only to Navigate to ANOTHER page.Syntax is as Below
< asp:HyperLink NavigateUrl="pageName.aspx" runat="server" />

(3)Response.Redirect:- Its used to navigate to another page from code. This is EQUIVALENT to clicking a hyperlink. Syntax is as Below
Response.Redirect("PageName.aspx")

(4)Server.Transfer:-End the current Web form and begin executing a new Web form. This method works only when navigating to a Web Forms page (.aspx).
Server.Transfer("PageName.aspx");

(5)Server.Execute:- Begin executing a new Web form while still displaying the current Web form. The CONTENTS of both forms are combined. This method works only when navigating to a Web Forms page (.aspx).
Server.Execute(path)

19.

LinkButton property to open a url in new tab from code?

Answer»

LinkButton property to OPEN a url in new tab from code?
Here in below code we use LinkButton control to create a hyperlink-style BUTTON on the Web page. In Below code LinkButton control has the same appearance as a HyperLink control and on another SIDE it has the same functionality as a Button control. And if we need to open link to another Web page/other tab when the LinkButton is is clicked. Below is the code for both c#.net and vb.net:-

c# code
LinkButton1.Attributes.Add("href","../TestURL.aspx");
LinkButton1.Attributes.Add("target","_blank");


vb.net code
Dim lnkbtn as LinkButton = e.Row.FindControl("LinkButton1")
lnkbtn.Attributes.Add("href","../TestURL.aspx")
lnkbtn.Attributes.Add("target","_blank")

20.

Code to use http to https permanent in config file?

Answer»

Code to use HTTP to https permanent in CONFIG file?
Below is the code to use to TRANSFER permanent http to https:-



http to https

or we can write below code

protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.IsSecureConnection.Equals(FALSE) && HttpContext.Current.Request.IsLocal.Equals(false))
{
Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"]
+ HttpContext.Current.Request.RawUrl);
}
}

21.

Can we set Master Page dynamically?

Answer»

Can we set Master Page dynamically?
Yew, we can CHANGE Master Page dynamically. But to change this we use MasterPageFile property to be set only in the PreInit EVENT. Below is the syntax of set Master Page dynamically:-

void Page_PreInit(Object SENDER, EventArgs E)
{
this.MasterPageFile = "~/MasterPageID.master";
}

22.

Name the security control available in dotnet?

Answer»

Name the security control available in dotnet?
Below are the FIVE main security CONTROLS available in asp.net:-
(1)asp:Login:-This control PROVIDE a login CAPABILITY which enable the user to enter there credentials with ID and password fields.
(2)asp:LoginName:-This control is mainly used to display which user is logged-in.
(3)asp:LoginView:-This control will provide a number of views depending on the TEMPLATE that has been selected.
(4)asp:LoginStatus:-This is control is used to check whether user is authenticated or not.
(5)asp:PasswordRecovery:-This control will sends and email to user while resetting the password.

23.

Dotnet Validation of viewstate MAC failed?

Answer»

Dotnet Validation of viewstate MAC failed?
Some time we will get error LIKE below given in viewstate MAC failed:-
Sys.WebForms.PageRequestManagerServerErrorException: Validation of viewstate MAC failed. If this application is HOSTED by a Web Farm or CLUSTER, ensure that < machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Below are the some option to resolve this


Viewstate Mac error

24.

File upload in dotnet

Answer»

Here is the html CODE of the webpage
asp:FileUpload ID="FileUpload1" runat="SERVER"
asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#0033CC" Visible="False"

Here is the code behind file
protected void btnUpload_Click(OBJECT sender, EventArgs E)
{
if (FileUpload1.HasFile)
{
try
{
string filePath = Server.MapPath("./") + System.IO.Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs(filePath);
lblMessage.Text = "File UPLOADED to " + filePath;
lblMessage.Visible = true;
}
catch (Exception ex)
{
throw ex;
}
}
}

25.

Use of Calendar control in dotnet with code

Answer»

Use of CALENDAR CONTROL in dotnet with code
Calendar Control is server SIDE control in asp.net which is used to do postback when we need to put that in textbox or LABEL as given IB below tables.
(1).aspx page


CalendarControl ASPX
(2).aspx.cs page


CalendarControl CS Page

26.

How to improve Front End UI performance of dotnet web application?

Answer»

How to improve FRONT End UI performance of dotnet web application?
Below are the five main POINTS to improve performance of asp.net web application.
(1)If we are doing on responsive pages then always tried to use PROVED frameworks like Bootstrap donot depend on your code written for this to improve performance of the application.
(2)If our web application contains lot of images or videos then always use appropriate CDS(Content Delivery Network).
(3)Always TRY to do bundling and minification techniques which improves the performance by reduce the server calls to load the Javascript and CSS files. And this will reduce the loding time of pages.
(4)Always try to use table less DESIGN and in place of table use div tag which will improve the performance of page.
(5)If we have number of records on our page always try to use "Paging" for example if we have 500 records on our page then try to use "20" records on one page.

27.

function of garbage collector

Answer»

Here is the some of basic function of garbage collector
(1)Garbage collector first function to RESERVES a piece of memory as the APPLICATION starts for the managed heap.
(2)After that Garbage collector controls the managed heap memory currently used and available to an application.
(3)Garbage collector also helps to allocates memory for new OBJECTS within the application.
(4)The Garbage Collector attempts to reclaim the memory of objects that are not referenced in the application.

28.

Difference between Public and Private Assembly?

Answer» DIFFERENCE between PUBLIC and PRIVATE ASSEMBLY?
Below are the some of COMMON difference between Public and Private Assembly.
29.

Main difference between DirectCast and CType?

Answer» MAIN DIFFERENCE between DIRECTCAST and CTYPE?
Below are the main difference between DirectCast and CType
30.

No HTTP handler was found for request type get error in MSCharts?

Answer»

No HTTP handler was found for REQUEST type get error in MSCHARTS?
In Visual STUDIO when we are using CHART control and while publishing code we will get such error to resolve this we need to do some settings in web.config as this issue is with HTTPHandler.
Add below lines in web.config and try


MSChart Error
And need to add below value on .ASPX page


MSChart Register

31.

What do you mean by XSS?

Answer»

What do you mean by XSS?
XSS is also known as Cross Site SCRIPTING. We can also say XSS or CSS are same. XSS is one of the most COMMON application LAYER web attacks. XSS mainly TARGETS scripts embedded in a page that is executed on client-side rather than on the server-side.

32.

Which of the control cannot be placed in MDI?

Answer»

Which of the CONTROL cannot be PLACED in MDI?
All the CONTROLS that do not have any EVENTS cannot be placed in MDI.

33.

How to disable HTTPS in visual studio 2017 web project dotnet core?

Answer»

How to DISABLE HTTPS in visual STUDIO 2017 WEB project dotnet core?
Whever we will run our web project it will be run in any browser. Some time it starts with HTTPS and this will cause some issue in running in some third party tools. So we need to run APPLICATION with http in place of https. Below are different images that will help us on this.


Enable SSL

HTTPS to HTTP

Remove HTTPS

34.

How to update EF Core tools in dotnet?

Answer»

How to UPDATE EF Core tools in dotnet?
When we use asp.net EF tools in VS 2017 package manager console we get some warning message about to update EF Core tools.

(1)By using command LINE, CMD or PowerShell for SPECIFIC version.
dotnet tool update --GLOBAL dotnet-ef --version 3.1.0

(2)And for latest version use below command
dotnet tool update --global dotnet-ef