19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 19 n Finding Vulnerabilities in Source Code 719<br />

API<br />

Cookies<br />

Files<br />

InputStream<br />

BinaryRead<br />

HttpMethod<br />

Browser<br />

UserAgent<br />

AcceptTypes<br />

UserLanguages<br />

DESCRIPTION<br />

Returns a collection of Cookie objects, which contain<br />

details of <strong>the</strong> cookies received in <strong>the</strong> request, including<br />

<strong>the</strong>ir names and values.<br />

Returns a collection of files uploaded by <strong>the</strong> user.<br />

Return different representations of <strong>the</strong> raw request<br />

received from <strong>the</strong> client and <strong>the</strong>refore can be used<br />

to access any of <strong>the</strong> information obtained by all <strong>the</strong><br />

o<strong>the</strong>r APIs.<br />

Returns <strong>the</strong> method used in <strong>the</strong> HTTP request.<br />

Return details of <strong>the</strong> user’s browser, as submitted in<br />

<strong>the</strong> HTTP User-Agent header.<br />

Returns a string array of client-supported MIME types,<br />

as submitted in <strong>the</strong> HTTP Accept header.<br />

Returns a string array containing <strong>the</strong> languages<br />

accepted by <strong>the</strong> client, as submitted in <strong>the</strong> HTTP<br />

Accept-Language header.<br />

Session Interaction<br />

ASP.NET <strong>application</strong>s can interact with <strong>the</strong> user’s session to store and retrieve<br />

information in various ways.<br />

The Session property provides a simple way to store and retrieve information<br />

within <strong>the</strong> current session. It is accessed in <strong>the</strong> same way as any o<strong>the</strong>r indexed<br />

collection:<br />

Session[“MyName”] = txtMyName.Text;<br />

// store user’s name<br />

lblWelcome.Text = “Welcome “+Session[“MyName”]; // retrieve user’s name<br />

ASP.NET profiles work much like <strong>the</strong> Session property does, except that <strong>the</strong>y<br />

are tied to <strong>the</strong> user’s profile and <strong>the</strong>refore actually persist across different sessions<br />

belonging to <strong>the</strong> same user. Users are reidentified across sessions ei<strong>the</strong>r<br />

through au<strong>the</strong>ntication or via a unique persistent cookie. Data is stored and<br />

retrieved in <strong>the</strong> user profile as follows:<br />

Profile.MyName = txtMyName.Text;<br />

// store user’s name<br />

lblWelcome.Text = “Welcome “ + Profile.MyName; // retrieve user’s name<br />

The System.Web.SessionState.HttpSessionState class provides ano<strong>the</strong>r<br />

way to store and retrieve information within <strong>the</strong> session. It stores information

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!