- Posted On 27 April 2014
- By
- In Interview Questions
Thanks for your nice response to my previous posts of interview questions series. In first and second post I had shared some advanced questions on Garbage Collection in C# in PART1 and PART2 then I had shared some interview questions on C# and also some very important tips on how to crack interviews and in today’s post I will share some interview questions on ASP.NET C#.
All these questions I had faced during my last job hunt in Pune for Senior Software Engineer. Hope you will find it useful. Here are the questions with their answers.
Both master page and content page has its own page load event. What you think whose page load event gets fired first?
If you are working in ASP.NET then Master page and content page is very well known. Coming to the answer, Master’s page load event gets fired after Content page load event.
The general rule for how events are raised is that the initialization events are raised from the innermost control to the outermost one, and all other events are raised from the outermost control to the innermost one. It is helpful to remember that the master page is merged into the content page and treated as a control in the content page.
My website is developed in ASP.NET and hosted on some server but whenever I visit my site in morning or you can say on first visit it takes more time to load but after that it loads faster. What you think why this is happening and how can I avoid it?
This is more live scenario so if you are having nice experience in developing web applications using ASP.NET then it is expected from you to answer this question.
To answer this question, this is happening because on first request application gets compiled first and compiled assemblies are cached and reused on subsequent requests. So to reduce the time of first request you can precompile the application so on first request it will not get compiled again which will reduce the loading time.
You can read more about precompiling the web applications at MSDN below.
Precompiling asp.net applications
I generally precompile my asp.net site using web deployment tool.
To add more to this answer, enabling autostart and always running mode feature of application pool too can reduce the loading time drastically. We can enable this through code behind in Global.asax.cs.
Soon I will share information about how to enable it. So keep visiting to get updated or I will recommend subscribing to my site which will notify you about my latest posts.
Let’s move to the next question.
Suppose your PM calls you and tell you that there is one asp.net project in which all developers have passed query string in plain text and now client want those query strings in encrypted format and we have only 3 hours in hand. (Encryption and decryption logic is available) then how will you handle this situation and how this can be done?
Well, before you read answer try to think how this can be done so you can test your answer with correct one and just to share, this question is asked by project manager in my last technical round. I had started my answer with "If there is a base class implemented and each page is inherited from that then....." but wait that project manager broke my answer here only and said that "base class too is not implemented, then…."
So to answer, it can be done implementing custom HTTP Module for your application. You can extend life cycle of asp.net application through IHttpModule classes which can raise events on each request of the application.
This is sufficient answer as it shows that you know what HTTP module is and how it works. If you don't know much about HTTP Module then you must read about it on MSDN here because knowing HTTP Module is very important if you are appearing interview for the senior post.
How to show custom message like “Don’t be smart! This is restricted page." if someone tries to access your web.config file by changing URL in browser?
It is well known that you cannot directly browse web.config as like other pages of your site and all this care taken by the by IIS itself. But this question is somehow different.
To answer, it can be achievable by implementing custom HTTP Handler for ".config" extension. An ASP.NET HTTP handler is the process that runs in response to a request that is made to an ASP.NET Web application. So once you map extension to your HTTP handler, so whenever user requests a file with mapped extension, that request gets processed by mapped handler's ProcessRequest metnod.
What is the difference between HTTP and SOAP?
HTTP and SOAP both are protocols used by Web Services for communication. More specifically HTTP is Transport Protocol and SOAP is Messaging Protocol. Messaging protocols are responsible for exchanging the messages in a commonly agreed format and Transport protocols are responsible for delivering the messages and how it should communicate.
You can remember this by real world example i.e. You call your friend(boy or girl choose as appropriate :-) ) on mobile and you speak with him/her in English, then in this case your mobile is "HTTP" and "English" is SOAP.
Hope these answers have helped you in your preparation of interview. Do share your thought and more questions you know in comment section below. It will help me to share more questions more specifically answers :-) in my future posts.
- Tags :
- ASP.NET
- InterviewQuestions
- CSharp
Advanced .NET Interview Questions - Garbage Collection - Part 1
This post contains some advanced .NET Interview Questions on the topic Garbage Collection.
Advanced .NET Interview Questions - Garbage Collection - Part 2
This post contains some advanced .NET Interview Questions on the topic Garbage Collection.
Advanced Interview Questions and answers on C#.NET - Part 1
In this post we will discuss some advanced interview questions on C#.NET. which will help you to understand the type of questions asked in interviews for senior software engineer post.
How to Prepare for the interviews - Simple but important tips - Part 3 - Prepare for HR Round
In this third post of my interview tips series, I am going to share some tips about how to prepare for HR Round. Also about things to do and things to not to do during the same.
How to Prepare for the interviews - Simple but important tips - Part 1 - Resume Writing
In this post I will share some interview tips from my own personal experience which will help you to prepare for the interview. In part one I will cover how to design a resume which will put your first impression smartly.