Changing SessionID Dynamically In C#?
Jan 29, 2010
if there is a way to dynamically change the session ID from the context of a SessionStateStoreProvider (or some other customizable module) in C# for ASP.NET.
I am implementing a custom SessionStateStoreProvider, and I was thinking about augmenting the session ID to tell the store provider where to go look for a session. I've implemented a custom SessionIDManager, which lets me augment newly created session IDs with the required tag. The problem is that the desired value of that tag might change during the life of a session. For example, the session may be read from one location, but may need to written to a different location. In this instance the ID would have originally been tagged for location A, but on writing the store would want to write to location B. The tag should be updated to reflect location B for the next session read.
So, from the context of SessionStateProviderBase override...
public override void SetAndReleaseItemExclusive(HttpContext context,
string id, SessionStateStoreData item, object lockId, bool newItem)
... is it possible to change the session ID? I know that the HttpContext.Session.SessionID property is not settable. Is there some other way to feedback an update like this? Or is there a more appropriate to carry state like this across calls?
View 2 Replies
Similar Messages:
Aug 29, 2012
working on .net 2.0 using (vb)
I have used Session.SessionID property, but it's keep on changing on every page postback.....can we keep it same untill user sign out from his account..?
View 1 Replies
Feb 3, 2011
this may or may not be a big deal but what I am looking to do is based on some data returned to my view I want to change the background-color to what value is being returned. Black, Yellow, etc.... How can I in my aspx page set my Style background-color based on this value in the model. I know Attributes are used in Web forms control but not sure in MVC how to do this
View 3 Replies
May 13, 2010
I haven't had any luck finding the answer yet. My problem is that I want to be able to update the dataformatstring on a gridview column at runtime. For example, I switch from displaying # of units to cost of said units... and I want to change the format of the column to {0:c}. It seems like it should be a simple task.
View 2 Replies
Dec 16, 2010
Good sample for dynamically change theme in MVC 3 RC 2 (Razor).
View 1 Replies
Sep 11, 2010
You fetch the user's IP address and based on his/her country you redirect the user to a specific webpage. Now, how do you change the master page dynamically? This is how I am redirecting the user :-
Geolocation Error with IP Address 127.0.0.1
It's not like the user clicks some button or something and you then change the master page. I want it changed when the user is redirected, so how exactly do I go about it?
public partial class testClass: System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (redirected to site1)
{
Use this master page1
}
else
if (redirected to site2)
{
Use this master page2
}
}
}
So how do I check what SITE the user has been redirected to? Also HOW to apply the specific master page now that the user has been redirected?
I just need an idea how to go about it.
[EDIT] please check the code block below. How do I fetch the URL that the user has been redirected to? I actually need just the "iso3166TwoLetterCode" variable's value (see the link to my earlier question, please) and based on that will be changing the master page. I can't figure out how to fetch that value or even use that class (that's got this variable) in my testClass.
protected void Page_PreInit(object sender, EventArgs e)
{
if (user Has been redirected to www.site.in )
{
this.MasterPageFile = "master1.master";
}
if (user Has been redirected to www.site.fr )
{
this.MasterPageFile = "master2.master";
}
}
View 2 Replies
Jun 15, 2010
I am working for a project on disaster management sponsered by World Bank, under this project i have assigned work on CMS. and my senior has asked me to make a ASP.NET webpage where those logged with administrator privilege will be able to edit the page.
like:-
<div id="mydiv"><pre>+++++++MY CONTENT+++++++++++++++++++</pre></div>
now if if the admin clicks on mydiv he should be able to edit the pre contents.
for this i got many options such as WYSIWYG editors (but they work on textboxs only and further more they cant save the data back to server replacing the previous content) then I came to know about Webparts , but its editing capabilities was so low that my plan for implementing a WYSIWYG editor went in vain.
View 1 Replies
Mar 8, 2010
We have a database with around 5000 records in it. We also have a web page that displays many of the fields. One field is an nText field and displays up to several paragraphs. My customer wants me to add those A+ and A- buttons for increasing and decreasing the font size for this field. My problem is that many of the older records have quite a bit of formatting in the field. Most of the rest contain styles dictating a font size of 12 px. Is there a way to increase and decrease the font soze of the text without modifying all the records?
Here's an example:
[code].....
View 8 Replies
Sep 13, 2010
I created this master page file and in its Page_PreInit added the code to change master page at run time after detecing a visitor's country:-
Now, while researching I came across this thread that says "Setting the master page in Page_PreInit event is against the design and spirit of MVC..what is this supposed to mean ???
If not this way, how else am I supposed to change master pages at run time???
View 1 Replies
Aug 19, 2010
I'm working on a project that have 3 diffrent type of users with 3 diffrent master pages. I can verfiy there access level and let them view pages but after googling I came accross a tutorial form asp.net but it wasn't very helpfull the code I got listed below works only if the session is at null, It dosen't seem to pull the session value.
[Code]....
there is a class page attached to it but nothing seems to work. I've downloaded the tutorial but it wasn't any clearer than what I read.
I 'm just trying not to have to code over the joint pages.
View 3 Replies
May 24, 2010
The basic idea is we have a test enviroment which mimics Production so customErrors="RemoteOnly". We just built a test harness that runs against the Test enviroment and detects breaks. We would like it to be able to pull back the detailed error. But we don't want to turn customErrors="On" because then it doesn't mimic Production.
I've looked around and thought a lot, and everything I've come up with isn't possible. Am I wrong about any of these points?
We can't turn customErrors on at runtime because when you call configuration.Save() - it writes the web.config to disk and now it's Off for every request.We can't symlink the files into a new top level directory with it's own web.config because we're on windows and subversion on windows doesn't do symlinks.
We can't use URL-Mapping to make an empty folder dir2 with its own web.config and make the files in dir1 appear to be in dir2 - the web.config doesn't apply. We can't copy all the aspx files into dir2 with it's own web.config because none of the links would be consistent and it's a horrible hacky solution.
We can't change customErrors in web.config based on hostname (e.g. add another dns entry to the test server) because it's not possible/supported. We can't do any virtual directory shenanigans to make it work.
If I'm not, is there a way to accomplish what I'm trying to do? Turn on customErrors site-wide under certain circumstances (dns name or even a querystring value)?
View 2 Replies
Jul 29, 2010
I have 3 aspx pages (page1.aspx, page2.aspx, page3.aspx). I also have a usercontrol for meta tags and page title. The usercontrol is called MetaTitle.ascx. This user control is being used in many pages. So I want to change a page title <title> dynamically in this usercontrol. But its not working. Here is the code:
MetaTitle.ascx:
<meta
name="Keywords"
content=""
/>meta
name="Description"
content=""
/>
[code]....
View 4 Replies
Nov 15, 2010
I have a grid view that I want to dynamically change based on data in my page. Specifically I want to change one of the title items and I want to hide a column based on a certain condition.
View 3 Replies
Feb 1, 2011
iam using ASP gridview. And i declare one label in headertemplate for setting heading of a particular column. How can i dynamicallly change the header text on a particular button click..
View 2 Replies
Oct 15, 2010
I'm writing a script and need with being able to modify the ImageUrl property in a HyperLink control from the code behind page. It is meant to dynamically show an image.
I just need to know the correct format of the code behind to get this to work.
View 2 Replies
Jan 20, 2010
im using AnimationExtender 2 fadeout a panel n d click event of a image..im using sme 10 images n same page and shld i write separate AnimationExtender for all images...
how 2 change d targetcontrolid of d animation extender n a javascript function....
View 1 Replies
Apr 7, 2010
EDIT: Purpose of this Website: Its called Utopiapimp.com. It is a third party utility for a game called utopia-game.com. The site currently has over 12k users to it an I run the site. The game is fully text based and will always remain that. Users copy and paste full pages of text from the game and paste the copied information into my site. I run a series of regular expressions against the pasted data and break it down. I then insert anywhere from 5 values to over 30 values into the DB based on that one paste. I then take those values and run queries against them to display the information back in a VERY simple and easy to understand way. The game is team based and each team has 25 users to it. So each team is a group and each row is ONE users information. The users can update all 25 rows or just one row at a time. I require storing things into cache because the site is very slow doing over 1,000 queries almost every minute.
So here is the deal. Imagine I have an excel EDIT(Excel is just an example of how to imagine it, I don't actually use excel) spreadsheet with 100 columns and 5000 rows. Each row has two unique identifiers. One for the row it self and one to group together 25 rows a piece. There are about 10 columns in the row that will almost never change and the other 90 columns will always be changing. We can say some will even change in a matter of seconds depending on how fast the row is updated. Rows can also be added and deleted from the group, but not from the database. The rows are taken from about 4 queries from the database to show the most recent and updated data from the database. So every time something in the database is updated, I would also like the row to be updated. If a row or a group has not been updated in 12 or so hours, it will be taken out of Cache. Once the user calls the group again via the DB queries. They will be placed into Cache.
The above is what I would like. That is the wish.In Reality, I still have all the rows, but the way I store them in Cache is currently broken. I store each row in a class and the class is stored in the Server Cache via a HUGE list. When I go to update/Delete/Insert items in the list or rows, most the time it works, but sometimes it throws errors because the cache has changed. I want to be able to lock down the cache like the database throws a lock on a row more or less. I have DateTime stamps to remove things after 12 hours, but this almost always breaks because other users are updating the same 25 rows in the group or just the cache has changed.This is an example of how I add items to Cache, this one shows I only pull the 10 or so columns that very rarely change. This example all removes rows not updated after 12 hours:
DateTime dt = DateTime.UtcNow;
if (HttpContext.Current.Cache["GetRows"] != null)
{
[code]...
View 4 Replies
Nov 13, 2010
What would be the best way of going about doing this;
On my website I am putting some short stories in and allowing people to change the name of the characters in the story to match their own. I was going to keep the stories in a SQL DB but not quite sure how I would go about changing the names of the characters dynamically?
Would I be best using say (Name1), (Name2) etc in the stories in the DB then changing it using a string query on the code behind or is there a better / quicker way to acheive this?
View 3 Replies
Apr 19, 2012
What I need to do is perform some kind of decision statement and when true I need to change the backcolor of a treenode to grey, so that it has a grey box around the whole text. There is no backcolor property for the tree node and I don't need it applied all the time so I don't think a CSS class will do this.
View 4 Replies
Nov 12, 2010
I have a reportViewer control and I dynamically setting the report path and dataset in the page load event if it is not a post back. This first report displays without issue. However, when I attempt to change the report path / dataset via the onChange event from a dropdown list I get the following error:
A data source instance has not been supplied for the data source "Summary_DataTable1".
This code works fine and the summary report is displayed the first time the page is loaded.
[code]....
View 6 Replies
May 21, 2010
I want to dynamically change the color of the web page based on the day of the month. I'll hard code the colors for the 1st, 2nd, etc., but I need to test for the date and choose the color.
View 3 Replies
Oct 25, 2010
I have the following table row on my .aspx page.
[Code]....
I can change the color of the return value based on conditional statements but cannot figure out the correct syntax to change the table cell back ground. My attempt is commented out.
How do I correctly declare the table cell? Findcontrol must not be the correct way.
View 1 Replies
Oct 26, 2010
I have a page to show a thread content, it take the ID of the thread from the query string.
depending on the ID, I show the content using the FormView control.
how could I then change the page title depending on the databinding result?
I've figured out that I can do that before the databinding in the Page_Load event, by querying the title of the thread depending on the ID from the QueryString object, but I'm wondering if I can achieve my goal during the databinding!
View 1 Replies
May 12, 2010
I have to be able to dynamically change the sproc name that is used in a Linq to SQL query. I see in the dbml designer this:
[Function(Name="dbo.InsertUnknownMessage")]
View 4 Replies
Nov 1, 2010
How do i dynamically change the value of dataitem in repeater control(.net 2.0,VS 2005)..i have repeater something like this :
<asp:Repeater ID="rptGameInfo" runat=server OnItemDataBound="itemDataBound_rptGameInfo" >
<HeaderTemplate >
</HeaderTemplate>
<ItemTemplate >
<asp:Label ID="lblLoc" runat=server Text="Location:" ></asp:Label><%# Eval("GAME_LOCATION")%><br />
</ItemTemplate >
</asp:Repeater>
and it shows the result like this:
location:"Select"
If location is "Select" i want to change it to "n/a". So i am trying to capture it in itemDataBound even something like this
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
DataRowView row = e.Item.DataItem as DataRowView;
string location = row["GAME_LOCATION"].ToString();
if (location == "Select")
{
// e.Item.Text = "n/a";>>
}
Does e.Item some 'text' sort of property ,i can set the value to?
View 4 Replies