C Sharp DotNet interview questions.docx
- 文档编号:29868665
- 上传时间:2023-08-03
- 格式:DOCX
- 页数:123
- 大小:95.85KB
C Sharp DotNet interview questions.docx
《C Sharp DotNet interview questions.docx》由会员分享,可在线阅读,更多相关《C Sharp DotNet interview questions.docx(123页珍藏版)》请在冰豆网上搜索。
CSharpDotNetinterviewquestions
ASP.NET
Whatisviewstateanduseofit?
ThecurrentpropertysettingsofanASP.NETpageandthoseofanyASP.NETservercontrolscontainedwithinthepage.ASP.NETcandetectwhenaformisrequestedforthefirsttimeversuswhentheformisposted(senttotheserver),which allowsyoutoprogramaccordingly.
Whatareusercontrolsandcustomcontrols?
Customcontrols:
Acontrolauthoredbyauserorathird-partysoftwarevendorthatdoesnotbelongto the.NETFrameworkclasslibrary.Thisisagenerictermthatincludesusercontrols.A customservercontrolisusedinWebForms(ASP.NETpages).Acustomclientcontrolisused inWindowsFormsapplications.
UserControls:
InASP.NET:
Auser-authoredservercontrolthatenablesanASP.NETpagetobere-used asaservercontrol.AnASP.NETusercontrolisauthoreddeclaratively andpersistedasa textfilewithan.ascxextension.TheASP.NETpageframeworkcompilesausercontrolon theflytoaclassthatderivesfromthe System.Web.UI.UserControlclass.
Whatarethevalidationcontrols?
AsetofservercontrolsincludedwithASP.NETthattestuserinputinHTMLandWebserver controlsforprogrammer-definedrequirements.Validationcontrolsperforminputcheckingin servercode.IftheuserisworkingwithabrowserthatsupportsDHTML,thevalidation controlscanalsoperformvalidationusingclientscript.
What'sthedifferencebetweenResponse.Write()andResponse.Output.Write()?
Thelatteroneallowsyoutowriteformattedoutput.
Whatmethodsarefiredduringthepageload?
Init()
Whenthepageisinstantiated,Load()-whenthepageisloadedintoserver memory,PreRender ()-thebriefmomentbeforethepageisdisplayedtotheuser asHTML, Unload()- whenpagefinishesloading.
WheredoestheWebpagebelonginthe.NETFrameworkclasshierarchy?
System.Web.UI.Page
Wheredoyoustoretheinformationabouttheuser'slocale?
System.Web.UI.Page.Culture
What'sthedifferencebetweenCodebehind="MyCode.aspx.cs"andSrc="MyCode.aspx.cs"?
CodeBehindisrelevanttoVisualStudio.NETonly.
What'sabubbledevent?
Whenyouhaveacomplexcontrol,likeDataGrid,writinganeventprocessingroutineforeach object(cell,button,row,etc.)isquitetedious.Thecontrolscanbubbleuptheir eventhandlers,allowingthemainDataGrideventhandlertotakecareofitsconstituents.
SupposeyouwantacertainASP.NETfunctionexecutedonMouseOveroveracertainbutton.
Wheredoyouaddaneventhandler?
It'stheAttributesproperty,theAddfunctioninsidethatproperty.
e.g.btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
WhatdatatypedoestheRangeValidatorcontrolsupport?
Integer,StringandDate.
Whatarethedifferenttypesofcaching?
Cachingisatechniquewidelyusedincomputingtoincreaseperformancebykeeping frequentlyaccessedorexpensivedatainmemory.Incontextofwebapplication,cachingis usedtoretainthepagesordataacrossHTTPrequestsandreusethemwithouttheexpenseof recreatingthem.ASP.NEThas3kindsofcachingstrategiesOutputCachingFragmentCachingData
CachingOutputCaching:
Cachesthedynamicoutputgeneratedbyarequest.Sometimesitis usefultocache theoutputofawebsiteevenforaminute,whichwillresultinabetter performance.ForcachingthewholepagethepageshouldhaveOutputCachedirective.<%@OutputCacheDuration="60"VaryByParam="state"%>
FragmentCaching:
Cachestheportionofthe pagegeneratedbytherequest.Sometimesitisnotpracticaltocachetheentirepage,in suchcaseswecancacheaportionofpage<%@OutputCacheDuration="120"VaryByParam="CategoryID;SelectedID"%>
DataCaching:
Cachestheobjectsprogrammatically.For datacachingprovidesacacheobjectforeg:
cache["States"]=dsStates;
Whatdoyoumeanbyauthenticationandauthorization?
Authenticationistheprocessofvalidatingauseronthecredentials(usernameand password)andauthorizationperformsafterauthentication.AfterAuthenticationauserwill beverifiedforperformingthevarioustasks,Itaccessislimiteditisknownas authorization.
Whataredifferenttypesofdirectivesin.NET?
@Page:
Definespage-specificattributesusedbytheASP.NETpageparserandcompiler.Can beincludedonlyin.aspxfiles <%@PageAspCompat="TRUE"language="C#"%>
@Control:
Definescontrol-specificattributesusedbytheASP.NETpageparserand compiler.Canbeincludedonlyin.ascxfiles.<%@ControlLanguage="VB"EnableViewState="false"%>
@Import:
Explicitlyimportsanamespaceintoapageorusercontrol.TheImport directivecannothavemorethanonenamespaceattribute.Toimportmultiple namespaces, usemultiple@Importdirectives.<%@ImportNamespace="System.web"%>
@Implements:
Indicatesthatthecurrentpageorusercontrolimplementsthespecified.NET frameworkinterface.<%@ImplementsInterface="System.Web.UI.IPostBackEventHandler"%>
@Register:
Associatesaliaseswithnamespacesandclassnamesforconcisenotationin customservercontrolsyntax.<%@RegisterTagprefix="Acme"Tagname="AdRotator"Src="AdRotator.ascx"%>
@Assembly:
Linksanassemblytothecurrentpageduringcompilation,makingall the assembly'sclassesandinterfacesavailableforuseonthe page.<%@AssemblyName="MyAssembly"%><%@AssemblySrc="MySource.vb"%>
@OutputCache:
DeclarativelycontrolstheoutputcachingpoliciesofanASP.NETpageora usercontrolcontainedinapage<%@OutputCacheDuration="#ofseconds"Location="Any|Client|Downstream|Server|None"Shared="True|False"VaryByControl="controlname"VaryByCustom="browser|customstring"VaryByHeader="headers"VaryByParam="parametername"%>
@Reference:
Declarativelyindicatesthatanotherusercontrolorpagesourcefile shouldbedynamicallycompiledandlinkedagainstthepageinwhichthisdirectiveis declared.
HowdoIdebuganASP.NETapplicationthatwasn'twrittenwithVisualStudio.NETandthatdoesn'tusecode-behind?
StarttheDbgClrdebuggerthatcomeswiththe.NETFrameworkSDK,openthefilecontaining thecodeyouwanttodebug,andsetyourbreakpoints.StarttheASP.NETapplication.Go backtoDbgClr,chooseDebugProcessesfromtheToolsmenu,andselect aspnet_wp.exefrom thelistofprocesses.(Ifaspnet_wp.exedoesn'tappearinthelist,checkthe"Showsystem processes"box.)ClicktheAttachbuttontoattachtoaspnet_wp.exeandbegin debugging.
BesuretoenabledebuggingintheASPXfilebeforedebuggingitwithDbgClr.Youcan enabletellASP.NETtobuilddebugexecutablesbyplacinga
<%@PageDebug="true"%> statementatthetopofanASPXfileora
CanauserbrowsingmyWebsitereadmyWeb.configorGlobal.asaxfiles?
No.The
What'sthedifferencebetweenPage.RegisterClientScriptBlockandPage.RegisterStartupScript?
RegisterClientScriptBlockisforreturningblocksofclient-sidescriptcontaining functions.RegisterStartupScriptisforreturningblocksofclient-scriptnot packagedinfunctions-inotherwords,codethat'stoexecutewhenthepageisloaded. Thelatterpositionsscriptblocksneartheendofthedocumentsoelementsonthepage thatthescriptinteractsareloadedbeforethescriptruns.<%@ReferenceControl="MyControl.ascx"%>
Isitnecessarytolockapplicationstatebeforeaccessingit?
Onlyifyou'reperformingamultistepupdateandwanttheupdatetobetreatedasanatomic operation.Here'sanexample:
Application.Lock();
Application["ItemsSold"]=(int)Application["ItemsSold"]+1;
Application["ItemsLeft"]=(int)Application["ItemsLeft"]-1;
Application.UnLock();
Bylockingapplicationstatebeforeupdatingitandunlockingitafterwards,youensure thatanotherrequestbeingprocessedonanotherthreaddoesn'treadapplicationstate atexactlythewrongtimeandseeaninconsistentviewofit.IfIupdatesessionstate,shouldIlockit,too?
Areconcurrentaccessesbymultiplerequestsexecutingonmultiplethreadsaconcernwithsessionstate?
Concurrentaccessesaren'tanissuewithsessionstate,fortworeasons.One,it'sunlikelythattworequestsfromthesameuserwilloverlap.Two,iftheydooverlap,ASP.NETlocksdownsessionstateduringrequestprocessingsothattwothreadscan'ttouchitatonce.SessionstateislockeddownwhentheHttpApplicationinstancethat'sprocessingtherequestfiresanAcquireRequestStateeventandunlockedwhenitfiresaReleaseRequestStateevent.
DoASP.NETformsauthenticationcookiesprovideanyprotectionagainstreplayattacks?
Dothey,forexample,includetheclient'sIP addressoranythingelsethatwoulddistinguishtherealclientfromanattacker?
No.Ifanauthenticationcookieisstolen,itcanbeusedbyanattacker.It'suptoyouto preventthisfromhappeningbyusinganencryptedcommunicationschannel(HTTPS).Authenticationcookiesissuedassessioncookies,do,however,includeatime-outvalidthat limitstheirlifetime.Soastolensessioncookiecanonlybeusedinreplayattacksaslongastheticketinsidethecookieisvalid.Thedefaulttime-outintervalis30minutes.Youcanchangethatbymodifyingthetimeoutattributeac
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Sharp DotNet interview questions
![提示](https://static.bdocx.com/images/bang_tan.gif)