Response.Redirect() vs Server.Transfer()

Response.Redirect() should be used when:

  • we want to redirect the request to some plain HTML pages on our server or to some other web server
  • we don’t care about causing additional round trips to the server on each request
  • we do not need to preserve Query String and Form Variables from the original request
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)

Server.Transfer() should be used when:

  • we want to transfer current page request to another .aspx page on the same server
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server
  • we want to preserve Query String and Form Variables (optionally)
  • we don’t need to show the real URL where we redirected the request in the users Web Browser

enter image description here

Application, Session, Request, Response and HttpCookie

Application: 

All assignment shows outstanding deals.

System.Web.HttpContext.Current.Application[“Name”] = “Value”;
System.Web.HttpContext.Current.Application[“AppDB”] = “Remote USA”;

Session and Request:

Session[“RequestURL”] = Request.Url.ToString();

Response and HttpCookie:

A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site.

HttpCookie cookie = new HttpCookie(“Cookie”);
cookie.Value = “Hello Cookie! CreatedOn: ” + DateTime.Now.ToShortTimeString();
//this.ControllerContext.HttpContext.Response
this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);
if(this.ControllerContext.HttpContext.Request.Cookies.AllKeys.Contains(“Cookie”))
{
HttpCookie cookie = this.ControllerContext.HttpContext.Request.Cookies[“Cookie”];
cookie.Expires = DateTime.Now.AddDays(-1);
//this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);
this.ControllerContext.HttpContext.Response.Cookies.Remove(“Cookie”);
}

Web Programming Using the Razor Syntax (C#)

The programming using the  razor syntax shows outstanding deals.

The @ character starts inline expressions, single statement blocks, and multi-statement blocks:

Sample Code for:

@: [some text]

<text>some text</text>

@{
    var greeting = "Welcome to our site!";
    var weekDay = DateTime.Now.DayOfWeek;
    var greetingMessage = greeting + " Today is: " + weekDay;
}
<p>Today's weather: @weatherMessage</p>
<!-- Embedding a backslash in a string -->
@{ var myFilePath = @"C:\MyFolder\"; }
<p>The path is: @myFilePath</p>
@if(IsPost) {
    // This line has all content between matched <p> tags.
    <p>Hello, the time is @DateTime.Now and this page is a postback!</p>
} else {
    // All content between matched tags, followed by server code.
    <p>Hello <em>stranger</em>, today is: <br /> </p>  @DateTime.Now
}
@{
    @* This is a comment. *@
    var theVar = 17;
}

 

Models, Views, and Controllers

What does MVC look like?

MVC look like

All Posts MVC look like

URL Patterns

Result Type

for detail check this link

https://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult(v=vs.118).aspx

MVC Applications

•Models encapsulate objects and data
•Views generate the user interface
•Controllers interact with user actions
•Code in .cshtml and .cs files
•ViewBag
–Dynamic object for storing basic pieces of information
•Alias for ViewData
–Perfect for sending messages to the view
–Only available for that action
•Redirects cause the ViewBag to be emptied
TempData
–Just like the ViewBag, but it’s also available on the next page
We can save date

like this

viewData[“myobj”]=myobj

here “myobj” is the keyword in the deictionary and the object it is holding
against it is myobj and receive it like this in view

var auction = (mvcauction.models.myobj)ViewData[“myobj”]

it is receiving it not as a strongly typed object in fact as a object type and has to caste it in view we can use viewbag method to avoid it and receive object as  strongly typed object
like this

var myobj=viewbag.myobj

we can use better method by passing model like
return view(myobj);

var myobj=Model

MVC is a stateless architecture if u need to redirect user to another
request/action and giving him message of successful completion
tempdata is both exposed to controller and view tempdata is stored on server for exactly one request from the user if u assign data to it on one request it would be available to very next request

Action Name
Attributes

Analysis of Algorithm – Semester Work (40)

Semester Work (40)
BSCS Batch 2012 ——- (Regular Students)
Section :A
Sr. No. Roll  No. Name of Student Quiz Total Assignment Total Final Report/Paper Total
1 004-BSCS-12 USMAN ARSHAD 8 14 6 28
2 007-BSCS-12 ANNAM IRFAN 6 15 8 29
3 010-BSCS-12 MOIZ AHMAD 8 15 6 29
4 013-BSCS-12 ABDUL HANNAN KHAN 6 12 9 27
5 022-BSCS-12 USMAN ALI 8 15 13 36
6 025-BSCS-12 JAHANZAIB ISMAIL GONDAL 6 14 6 26
7 028-BSCS-12 MUHAMMAD SINWAN IJAZ 6 14 8 28
8 031-BSCS-12 SYED HASNAIN ALI SHAH GILLANI 8 15 15 38
9 034-BSCS-12 RIDA IFTIKHAR 9 14 11 34
10 037-BSCS-12 FAWAD AHMED 0 6 7 13
11 040-BSCS-12 ZAWAR MAHMOOD 6 13 8 27
12 043-BSCS-12 KHUSHBOO FATIMA 7 13 8 28
13 046-BSCS-12 HAMZA ALI 4 7 7 18
14 049-BSCS-12 MUDASAR HANIF 3 4 8 15
15 055-BSCS-12 MUHAMMAD ARSLAN BAJWA 0 8 5 13
16 058-BSCS-12 OMER RAHIM 4 15 10 29
17 061-BSCS-12 FATIMA RIAZ 8 15 9 32
18 062-BSCS-12 Fasil Fateh Khan 2 7 0 9
19 064-BSCS-12 HAMZA TAHIR 0 7 5 12
20 070-BSCS-12 FAIZAN SHAH 0 14 13 27
21 073-BSCS-12 RASIKH ALI ZAHID 0 14 9 23
22 076-BSCS-12 KHALID MAHMOOD 4 10 10 24
23 079-BSCS-12 MUHAMMAD IMRAN 4 10 6 20
24 082-BSCS-12 FAREEHA HAFEEZ 4 10 10 24
25 085-BSCS-12 INAAM UL HASSAN 8 15 5 28
26 088-BSCS-12 MUHAMMAD MUJTABA SHAHID 8 15 8 31
27 094-BSCS-12 NAIMA KHALID 6 6 9 21
28 097-BSCS-12 ARSLAN JAVAID 4 10 9 23
29 100-BSCS-12 MAHIR GULZAR 4 12 12 28
30 106-BSCS-12 SYED MUHAMMAD UMER 8 14 13 35
31 109-BSCS-12 MUHAMMAD ISHTIAQ 6 14 9 29
32 112-BSCS-12 AYYAZ AHMAD 8 15 13 36
33 115-BSCS-12 TAYYABA ANUM KHAN 6 14 8 28
34 117-BSCS-12 MUHAMMAD HAMZA HARIS 8 12 7 27
35 120-BSCS-12 GHIAS AHMED 6 14 8 28
36 123-BSCS-12 ZUNISH ZUBAIR 8 14 8 30
37 126-BSCS-12 WASIF ALI 8 11 5 24
38 129-BSCS-12 MADIHA 8 10 16 34
39 132-BSCS-12 SHER KHAN 6 10 11 27
40 135-BSCS-12 AYESHA SOHAIL 6 12 7 25
41 138-BSCS-12 USMAN SHAMSHAD 8 6 4 18
42 141-BSCS-12 ABDULLAH FARRUKH 6 9 6 21
43 144-BSCS-12 MUHAMMAD RAZA BUTT 8 15 11 34
44 147-BSCS-12 FATIMA RAFIQ 8 12 10 30
45 149-BSCS-12 ANAM IRFAN 8 15 11 34
                  Section: __________B_________
Sr. No. Roll  No. Name of Student Quiz(10) Assignment(15) Final Report/Paper(15) Total
1 002-BSCS-12 JAWAD IQBAL 0 8 8 16
2 006-BSCS-12 IQRA IQBAL 0 8 8 16
3 005-BSCS-12 MUHAMMAD ATIF MEHMOOD 4 11 6 21
4 008-BSCS-12 SYEDA FAIZA SOHAIL 3 10 8 21
5 011-BSCS-12 USMAN ZIA ULLAH 9 15 13 37
6 014-BSCS-12 MALIK BILAL MUBEEN AWAN 0 15 15 30
7 017-BSCS-12 MOAZ KHALID BUTT 0 12 9 21
8 020-BSCS-12 ZARRIN GULL FATIMA 6 12 7 25
9 023-BSCS-12 HUMA NAZ 3 9 5 17
10 026-BSCS-12 RANA HUZAIFA ABBAS 4 10 6 20
11 029-BSCS-12 MUHAMMAD KHURRAM BASHIR 8 13 8 29
12 032-BSCS-12 QAISER RASHID 5 15 13 33
13 035-BSCS-12 AOUNAIZA AHMED 7 15 6 28
14 038-BSCS-12 AWAIS AHMAD BHATTI 7 13 8 28
15 044-BSCS-12 HAMNA RASHID 0 13 12 25
16 056-BSCS-12 MUHAMMAD MOEEN UD DIN 0 15 15 30
17 062-BSCS-12 IKRAMULLAH 7 15 14 36
18 065-BSCS-12 H. M. SOHAIB FAROOQ 7 15 15 37
19 071-BSCS-12 JUNAID IRFAN 0 15 15 30
20 077-BSCS-12 FARRUKH BUTT 9 13 12 34
21 080-BSCS-12 FARYAL YOUSAF 4 12 10 26
22 083-BSCS-12 FATIMA ANWAR 3 10 16 29
23 086-BSCS-12 ASAD SHOAIB 7 7 6 20
24 089-BSCS-12 MUHAMMAD FARHAN ALI 7 11 7 25
25 092-BSCS-12 HUSSAIN ARSHAD 7 15 8 30
26 095-BSCS-12 MUHAMMAD SOHAIB QAISER 3 7 5 15
27 098-BSCS-12 SHAHBAZ AMIN 3 15 8 26
28 101-BSCS-12 JAWERIA ZAHID 3 15 10 28
29 104-BSCS-12 M. MAZHAR ABBAS ZAIDI 5 6 13 24
30 110-BSCS-12 H. SHERYAR NAWAZ 4 8 8 20
31 113-BSCS-12 AHMAD SALEEM 3 15 8 26
32 118-BSCS-12 FAHEEM ANWAR 0 9 7 16
33 121-BSCS-12 MUHAMMAD AIZAZ ATHAR 3 15 14 32
34 124-BSCS-12 SAJID ABBAS 5 8 4 17
35 127-BSCS-12 YAQOOT-E-AQSA 4 13 5 22
36 130-BSCS-12 ABDUL RHEMAN AMJAD 3 15 10 28
37 133-BSCS-12 MUHAMMAD ZEESHAN ALI 4 7 9 20
38 136-BSCS-12 RIZWAN ALI 5 11 8 24
39 139-BSCS-12 ZAEEM SATTAR 3 15 8 26
40 145-BSCS-12 WASIF ALI 5 11 6 22
41 152-BSCS-12 M. HAROON MEHMOOD 0 11 6 17
Semester Work (40) Section C
BSCS Batch 2012 ——- (Regular Students)
Roll  No. Name of Student Quiz Assignments Final Paper/Report Total
003-BSCS-12 MEMONA SALEEM 10 15 12 37
009-BSCS-12 MINAHIL AHMAD 10 8 6 24
012-BSCS-12 FAHAD HAMEED 4 8 8 20
015-BSCS-12 MUHAMMAD UMER ABIDIN 4 8 10 22
018-BSCS-12 MUHAMMAD ATTIQUE 6 8 8 22
021-BSCS-12 ARFA RAFIQ 10 10 8 28
024-BSCS-12 ZAHRA IMAD 10 10 10 30
027-BSCS-12 WAQAS ANJUM BALOOCH 4 10 6 20
030-BSCS-12 RABBIA GUL BUTT 10 11 6 27
036-BSCS-12 ABDUL MOIZ PAL 6 10 6 22
039-BSCS-12 ANZA KIBRIYA 10 8 6 24
042-BSCS-12 AYESHA TARIQ 8 11 6 25
045-BSCS-12 AZKA ABRAR 10 10 9 29
048-BSCS-12 SHOMAIL ALI NAJEEB 6 9 6 21
050-BSCS-12 USHNA HAREEM 6 10 6 22
051-BSCS-12 MUHAMMAD SOUD MUSHTAQ 6 8 6 20
054-BSCS-12 EHSAN ALI 4 10 6 20
057-BSCS-12 SYED IMRAN ALI 6 9 8 23
060-BSCS-12 SYEDA MEHAK FATIMA 0 11 9 20
063-BSCS-12 MUHAMMAD AMIR PERWAIZ 6 12 5 23
066-BSCS-12 UMER FAROOQ 4 10 8 22
069-BSCS-12 KHIZRA MUJAHID 6 8 8 22
075-BSCS-12 MUHAMMAD ABDULLAH 10 12 8 30
081-BSCS-12 MARIA TUL-ISLAM 10 15 9 34
084-BSCS-12 MARIA YOUNAS 6 8 8 22
087-BSCS-12 MUHAMMAD TAHIR ALI 10 12 8 30
090-BSCS-12 MUHAMMAD HAMAD 8 10 6 24
093-BSCS-12 AHMAD NAEEM ZAIDI 3 9 9 21
096-BSCS-12 RUHMA ASHRAF 10 10 6 26
099-BSCS-12 HUMZA MUSAB 4 12 6 22
102-BSCS-12 NAGEEN SALEEM 10 7 6 23
105-BSCS-12 HASSAN IQBAL DAR 6 9 6 21
108-BSCS-12 RIZWAN SUBHAN 4 10 7 21
111-BSCS-12 ZOYA LATIF 10 12 8 30
112-BSCS-11 BILAL HAFEEZ 0 12 8 20
114-BSCS-12 ASAD UL REHMAN 4 10 6 20
116-BSCS-12 USHNA KHALIL 8 11 6 25
119-BSCS-12 SHAHBAZ MUBASHAR 8 11 7 26
122-BSCS-12 HAROON SHAHZAIB NASIR 4 10 6 20
125-BSCS-12 MOHSIN ALI 8 10 6 24
128-BSCS-12 MUDASIR ABBAS 4 9 7 20
131-BSCS-12 ABDUL WAHAB 8 8 6 22
134-BSCS-12 IQRA ARIF 8 15 8 31
137-BSCS-12 MUHAMMAD UMAR BUTT 10 12 8 30
140-BSCS-12 MAUSAB ALI 6 8 5 19
143-BSCS-12 FAIZAN TARIQ 6 12 6 24
146-BSCS-12 WAJIHA BATOOL 8 12 7 27
148-BSCS-12 WAQAS TAHIR 6 12 6 24
153-BSCS-12 OSAMA TARIQ 8 8 6 22
155-BSCS-12 M. INAM ULLAH 6 9 6 21