C Sharp DotNet interview questions.docx

上传人:b****8 文档编号:29868665 上传时间:2023-08-03 格式:DOCX 页数:123 大小:95.85KB
下载 相关 举报
C Sharp DotNet interview questions.docx_第1页
第1页 / 共123页
C Sharp DotNet interview questions.docx_第2页
第2页 / 共123页
C Sharp DotNet interview questions.docx_第3页
第3页 / 共123页
C Sharp DotNet interview questions.docx_第4页
第4页 / 共123页
C Sharp DotNet interview questions.docx_第5页
第5页 / 共123页
点击查看更多>>
下载资源
资源描述

C Sharp DotNet interview questions.docx

《C Sharp DotNet interview questions.docx》由会员分享,可在线阅读,更多相关《C Sharp DotNet interview questions.docx(123页珍藏版)》请在冰豆网上搜索。

C Sharp DotNet interview questions.docx

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  statementinaWeb.configfile.

 

CanauserbrowsingmyWebsitereadmyWeb.configorGlobal.asaxfiles?

No.ThesectionofMachine.config,whichholdsthemasterconfiguration settingsforASP.NET,containsentriesthatmapASAXfiles,CONFIGfiles,andselected otherfiletypestoanHTTPhandlernamedHttpForbiddenHandler,whichfailsattemptsto retrievetheassociatedfile. Youcanmodifyitbyediting Machine.configorincludingansectioninalocalWeb.config file.

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

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1