Web Forms :: Set The Image Per The Session A Users Visits The Site Instead Of Each Page?

Jul 1, 2010

I have a background set of images that is called randomly.It changes each time a user opens a new page and refreshes the same page.Not 100% of what I want.

Ideally I would like a random image to be shown each time a user comes to the site but not on every page.

Is there a way to set the image per the session a users visits the site instead of each page?

Current code

SqlConnection connection = null;
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["PSI_DB_1ConnectionString"].ConnectionString.ToString());
connection.Open();
int id = Convert.ToInt32(Request.QueryString["id"]);
string SQLquery ="";
if (id == 0)
{
SQLquery = "Select Top 1 ImageData,ImageType from WebBGImages ORDER BY NEWID()";
}
else
{
SQLquery = string.Concat("Select ImageData,ImageType from WebBGImages where ImageID=",id);
}
SqlCommand Cmd = new SqlCommand(SQLquery, connection);
SqlDataReader Dr = Cmd.ExecuteReader();
if (Dr.HasRows)
{
while (Dr.Read())
{
Byte[] bytes = ((Byte[])Dr["ImageData"]);
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = Dr["ImageType"].ToString();
Response.BinaryWrite(bytes);
Response.End();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
}
}
Response.Flush();
Response.End();
Cmd.Dispose();
connection.Close();
connection.Dispose();

View 3 Replies


Similar Messages:

Web Forms :: How To Get IP Of Users System Machine When Visits Page

May 17, 2013

How I can get the IPS of all the computers through which users are accessing my website.

View 1 Replies

Web Forms :: Iframe Session / Site Session Starts Again On Every Page.postback

Dec 20, 2010

i have two web aplications running on different sites.

1. site gets user information and show another website (2. site) in an i frame. but when i do this 2. site session starts again on every page.postback . if i connect to 2. site without 1. site everything works well.

View 5 Replies

MVC :: Upload Image (path) To DB By Site Users

Feb 22, 2011

I'm trying to find a way for users to upload image to my site ,

In my db table I have a column name Image1 type image [allow null]

And I would like the user (among other fileds to fill, to upload image )

View 7 Replies

State Management :: Session Values Are Not Getting Stored If More Users Access The Site

Apr 2, 2010

l am facing a problem with session.

If many users access the site, the session gets crashed and data which i store to access across pages is getting lost.

a best way to store data (as session does) so that i can use the data across my web application.

View 5 Replies

Web Forms :: How To Track Number Of Visits Per Page

Sep 7, 2010

What I want is I that I want to keep track of number of visits per page and average time spent on each page and the site. I don't want to use any third (3rd) party tool. How to achieve this with minimum code.

View 5 Replies

Web Forms :: Count Total Unique Visits In Particular Page Of Website?

Dec 23, 2015

I want to count total unique visits in a particular page of my website using ASP.Net, C#. How i will do it

View 1 Replies

Security :: After Successful Creation Of 3 Users On My Web Site Now Cannot Create Users

Dec 6, 2010

[Code]....

after successful creation of 3 users on my web site now cannot create users

View 9 Replies

C# - Redirect Users To A Logged Out Page Once The Session Has Expired?

Jun 1, 2010

Can anyone tell me how to detect when a users session has exipred in asp? I want to redirect users to a logged out page once the session has expired.

View 3 Replies

Web Forms :: Transfer Image From One Page To Another Using Session

Nov 15, 2013

I have used a image handler to display image which works fine... My problem is how can v pass the image using sessions on different pages. I have an image control in master page and fileupload control on the content page.... bt m not able to implement sessions for images as image can't be store to string.

View 1 Replies

Coding To Enable Site Users Upload Pictures To Classifieds Site?

Nov 23, 2010

I've been using an asp 3.0 widget for this purpose , but it been broken for a while and rather than get it back up, I'd love o get a native asp.net solution, can any one point me in the right direction pleaseI once wrote some asp.net code to do this, but the permissions on the server, which I found to be common every where prevented asp.net native picture upload, perhaps i got it wrong, well now I wanna fix itI need the code to work in a shared hosting IIS 7 environment. I use vb.net, but can usually convert c# to vb.net

View 1 Replies

Web Forms :: Page Not Rendering Image From Session Variable

Apr 27, 2016

below is .ashx file shows error on If context.Session("photo1") <> "" Then why? I need to display an image on button click that saved in database.

imgHandler.ashx:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
If context.Session("photo1") <> "" Then
Dim bytes() As Byte = DirectCast(context.Session("photo1"), [Byte]())
context.Response.Buffer = True

[code]...

on display page on button click: 

Session("photo1") = HttpUtility.HtmlEncode(ds.Tables(0).Rows(0)("applicant_photo").ToString())
Image1.ImageUrl = "../imgHandler.ashx"

View 1 Replies

Url Trace / Want To Allow Only Visits From Facebook To See That Page

Jul 26, 2010

im tryin to figure how to do this, i have some web page and i want to allow only visits from facebook to see that page and anyone else will direct to other page how can i trace users that came from facebook to my site and direct them to special page and others to diffrent page?

View 13 Replies

Security ::web Site Runs But No Users Can Login To The Site>?

Dec 2, 2010

I have an application that uses the ASPNET role provider.My SQL Server crashed so I took a backup of the database and restored it to a new SQL Server and changed the db connection string to that server.The web site runs but no users can login to the site.Is there something that I should have done when the db was on the other server?

View 6 Replies

Tracking Unique Page Visits / Views?

Mar 28, 2010

I have an ASP.NET application where View.aspx page will display the details of each products in a shopping cart.The page displays dynamic data(Ex: For each product id,the content will be different).Now i want to track the unique page views of each product.What are the best solutions to approach this problem ? I am already using google analytics.But i wanna custom solution/code for my web app,so that i can know how many hits came for each product

View 2 Replies

State Management :: Upload Image To Session And Read From Session To Image Control?

Jan 9, 2011

i want to upload picture throw FileUpload control and then store it in session, after store in session i want to read it out to image control and insert to database.

View 3 Replies

State Management :: Counting Total Number Of Visits On Any Particular Page?

Aug 19, 2010

i am wishing to count total number of visits on any particular page with also the ability to work when IIS reset is done, i think by using database we can solve it.

how to count total number of visits on any particular page?

View 3 Replies

Custom Server Controls :: Building A User Control To Track Page Visits?

Mar 25, 2011

My intention is to give the user a flexible user control on a master page that does the following:

When navigating, a child page will pass the URL (with querystring) and PageTitle to the user control. The user control will take those two parameters and insert them as a "breadcrumb" object at first index of a List<breadcrumb> collection

This part works fine through the use of a Repeater with a LinkButton contained in an ItemTemplate. The user sees each of the pages he has been visiting in descending order, the provided benefit is a quick way to re-open records they have recently modified or created.

The part I'm having trouble handling is what happens when the user clicks the LinkButton, which is that the child page adds a new reference to the URL at the beginning of the List<> collection and I cannot seem to control the behavior of removing the LinkButton before it gets re-created. What I've tried doing is:

List<>.RemoveAt(RepeaterCommandEventArgs.Item.ItemIndex);
Repeater1.Controls.Clear();
Repeater1.DataSource = List<>;
Repeater1.DataBind();

While that should work, my CreateBreadCrumb(string url, string title) function gets called by the child page before the UserControl detects the Repeater1_ItemCommand event, so in effect it appears that the wrong ItemIndex is being used for removal.

View 1 Replies

Does Static Reference To HttpContext.Current.Session Return Same Session For All Users

Feb 4, 2011

Is there room for issue in the following code in terms of multiple users of the same web application? I mean, I know that a purely static string will be shared across all sessions for a single ASP.NET application, but since this explicitly refers to the Current.Session, even though it is static it seems like it would always refer to the session instance of the "current user." But an error is happening that could be explained by everyone sharing the current value of Mode and thus the most recent change overwriting everyone else's mode value. (As a background: This string is in a Helpers class that is used throughout the application. I do not want to make references to Session["Mode"] throughout the application and do not want to have to pass Session["Mode"] in every method call from an aspx.cs page.)

public static string Mode
{
get
{
var value = HttpContext.Current.Session["Mode"];
return (value ?? string.Empty).ToString();
}
set
{
HttpContext.Current.Session["Mode"] = value;
}
}

View 2 Replies

Web Forms :: Users To Change The Theme Of Site?

Feb 2, 2011

this is my code, i want my users to change the theme of my site.


[Code]....

View 4 Replies

User Controls :: How To Redirect To Login Page If User Directly Visits Page In MVC

Jun 11, 2013

i am developing one application in mvc my problem is after login it will redirect to some page if i copy url and paste it in another browser its showing error in application but i need to display home page? 

how to solve this ?

View 1 Replies

Image Upload Control (bonus - Allows Users To Crop Image Before Saving)

Apr 10, 2010

We have a scenario where we would like to allow our users to upload images to the site. We are running on ASP.Net. A quick search did not result in anything good. It would be great if the control is free/open source but we do not mind paying a little bit.

View 1 Replies

Web Forms :: How To Remember Users Input In Web Form During Session

Dec 1, 2010

I am new to C# , i've build a simple web form which shows a result based on 4 pulldown menus. I wish to save this result during the session the user spends on the website, untill the user resubmits the form. So when coming back to the result page, the search results are still shown.http://www.estatewise.nl to see the form in action.

View 3 Replies

Web Forms :: Session Variables Are Accessible To Multiple Users?

Oct 8, 2010

I have an asp.net website in which users can submit reports. Another tester and I tested this page at the same time and when I went to review the information I submitted, it displayed information that I didn't submit. It displayed the info submitted from the other user.

I use session variables for these values. I don't understand how this happened? What can I do so each user can individually submit their information without overlapping some one else's information? The plan is for multiple users to be able to use this page to submit their weekly layer reports.

The first example of code is how I add the session variables from the textboxes.

[Code]....

The second one is how I display them in labels on a confirmation page.

[Code]....

View 16 Replies

Web Forms :: Detect All Logged In Users In Web Application By Session Variable

Jan 28, 2011

I'm wondering if it's possible to perhaps set something up in the global.asx file or something that will build a list of all currently active user sessions that I can then use to display to a logged in user, who else is currently logged in.

Currently I store my userId's in a session variable Session["IsLoggedIn"], so basically i want to build an global array of some sort that will store all these active userId's.

Let me know if this is possible, or who i would go about accomplishing this sort of thing. BTW, I'm not using asp.net's built in membership thing for login accounts.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved