|
My web site uses a master page developed by a consultanting company, in which a custom control generates a session variable Session["Url"] that keeps the Url of the current page. After visiting several pages (all uses the same master page, Url1, Url2.....), I display the value of the Session["Url"] on my testing page that does not use the master page with one line of code:
Response.Write(Session["Url"].ToString());
It displays the last Url I visited. However, when I refresh this page continuously, I see a different value each time for all the pages I visited. Why does one session variable keeps multiple values? I could not duplicate this behavior with my own pages by assigning different values to Session["Url"] multiple times. It always stores the last value I assigned. Does anyone know why? This has created a big problem for me because the Session["Url"] is used to redirect a user back to where he comes from after login.
Thanks,
TOMZ_KV
|
|
|
|
|
Tomz_KV wrote: Why does one session variable keeps multiple values?
It does not. You have answered your own question in the next statement.
Tomz_KV wrote: I could not duplicate this behavior with my own pages by assigning different values to Session["Url"] multiple times.
check all the places where Session["Url"] is set. Since you are using the Master page which is developed by others, I am suspecting it being set somewhere else. I'd set a break point where the session variable is set and see what is happening.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Thanks for your reply.
I can't see the code in the custom control on the master page since it was compiled. My understanding is that no matter where Session["Url"] is set and how many times it is set, it should have only one value - the latest one. AS I said, when I displayed this variable on my testing page, every refresh showed a different value.
TOMZ_KV
|
|
|
|
|
I finally duplicated the behavior. By the way, the web application use InProc session state. Here is the process:
Session["Url"] value changed - I browse several pages that use the master page. Session["Url"] is set on each page I visited. Then I go to my testing page that DOES NOT use a master page to display the Session["Url"]. With each refresh of the testing page, I see a different value of the Session["Url"].
Session["Url"] value not changed - Code the testing page using the same master page. Go through the above steps. With each refresh of the page, Session["Url"] value is the same which is the Url of the current testing page.
This is very interesting. I could not found any documentation that explains this. Is this a designed behavior for asp.net?
TOMZ_KV
|
|
|
|
|
I can I detect if any textbox text values have changed before I commit the changes to the database?
|
|
|
|
|
In Javascript you can compare the object's "value" property with its "defaultValue" property.
Alternatively on the server you can have an object that has the value set on Page_Load or similar, and then on Postback you can compare whats in the Textbox with what your object's value is.
|
|
|
|
|
Which method is the preferred way of doing it and the least taxing on the server? I have 30 textboxes on the page.
|
|
|
|
|
Well I dont know enough about your situation to make that call. You could even do it at the database level if you are using stored procedures, but in most cases thats probably not a good idea.
Also what are you trying to accomplish specifically? If you dont want the user changing stuff why not just make the fields readonly?
If you have a specific reason why not and in a situation where you are already loading data from a database during a request, keeping it in a session object, and then showing that data to a user in a textbox, then on postback you will already have that data on your server and won't need to go back to the database to do your comparison, the original data is already there on the server. Personally I think it would be best practice to check it on the server. Since either way you are going to be testing equality on some field (be it a string or a changed-flag).
Are you validating any other fields on the page with javascript? Then you could lump your comparison in there with the validation, but then you'd need to create hidden fields and it might be too complex and not worth the small performance gain you would get when substituting a string compare with the changed field bool.
Sorry for rambling
|
|
|
|
|
The senerio I have is pretty simple. If the user makes any changes to the data in the textboxes on the page the logic that updates the database needs to update one of the table fields with a 0 otherwise use the existing value. Hence, I need to check if any changes were made on the page.
From what I have read using a session varable to store datatable rows is a server resource hog so instead I requery the database each time I need to.
And no I am not validating fields on the page with javajscript. Instead I have a class method to do the validating.
So to check if a user changed data on the page I should use some javascript?
|
|
|
|
|
If storing the data in a session is a problem for you then JavaScript will work, yes. Hope I've helped with your problem!
|
|
|
|
|
What kind of change are we talking about? Do any of the validation controls help you?
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
hy,
i made a Web Service project in visual studio 2008.
then added 2 "Web Service" files to the project.
Service1.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service1
Inherits System.Web.Services.WebService
<webmethod(true)> _
Public Function HelloWorld() As String
Session("foo") = "bar"
Return "Hello World"
End Function
End Class
Service2.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service2
Inherits System.Web.Services.WebService
<webmethod(true)> _
Public Function HelloWorld() As String
If Session("foo") <> "bar" Then
Throw New UnauthorizedAccessException
End If
Return "Hello World"
End Function
End Class
After i made a windows application, where i made a "Service Reference" to both web service classes/files.
The problem is that Service1.asmx doesn't share it's session with Service2.asmx,...
I get the thrown "UnauthorizedAccessException" on calling "Service2.HelloWorld()" because the session is not created in Service2.asmx after calling Service2...
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bhp As New System.ServiceModel.BasicHttpBinding
bhp.AllowCookies = True
Dim x As New ServiceReference1.Service1SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service1.asmx"))
Dim y As New ServiceReference2.Service2SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service2.asmx"))
MsgBox(x.HelloWorld)
MsgBox(y.HelloWorld)
' Dim x As New localhost.Service1
' MsgBox(x.HelloWorld())
' Dim y As New localhost1.Service2
' MsgBox(y.HelloWorld())
End Sub
End Class
How to share the session between those files,... In Visual Studio 2003 it works fine when calling the service from javascript,... Now in visual studio 2008 with the soap client wizards it doesn't...
Any help would be welcome,
...
It feels good to learn and achieve
|
|
|
|
|
i think it's impossible,
please tell me the answer
|
|
|
|
|
Hi All,
I have used a TreeView control which is placed in a Div tag in the master page. Whenever the TreeView controls items exceeds the limit of the Div tag it gives the vertical and horizantol scroll bars. It is Ok.
But when the items are not exceeding still it is giving the scroll bar in disable mode. What I want is the scroll bars should not appear when the items are within the limit means when the scroll bars are in disable mode they should not be visible and when they are enabled they should be automatically visible.
I want to do it by using any CSS class. Can anybody advice me to do it by using any CSS class.
Thanks,
Md Abdul Aleem
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
|
Hi All,
I read the link but I am unable to judge it satisfies my condition or not.
I have a div tag as below and I want to make the scroll bar invisible when the tree view control is within the div tags limit means when it is not required the scroll bars should become invisible and when the tree view opens and exceeds the limit of the div tag the scroll bars should come automatically.
<div id="TreeViewContainer2" class="inline">
<asp:TreeView ID="treeId" runat="server" SkinId="ExplorerLines" onselectednodechanged="treeId_SelectedNodeChanged" ExpandDepth="1" OnUnload="treeId_Unload" ForeColor="#000099"></asp:TreeView>
</div>
Can anybody please help me in doing this.
Thanks in advance,
Md. Abdul Aleem.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Hi,
I have some short questions about locking threads in ASP.NET. Normally I use C# console/winforms but in this case I need to write it in VB for ASP.NET. My questions are there any drawbacks to this code in a high-volume of requests? Is this completely wrong for an ASP.NET application? If so what do you recommend? The purpose here is to lock a timestamp and be sure it is set uniquely throughout all the sessions on the web server:
Protected Shared TimeStamp As Date
Protected Shared Sub SetUniqueTimeStamp()
Try
' Request the lock, and block until it is obtained.
Monitor.Enter(TimeStamp)
' When the lock is obtained, set the Timestamp.
TimeStamp = Now
Finally
'Guarantee at least 1ms tick for uniqueness
Thread.Sleep(1)
' Ensure that the lock is released.
Monitor.Exit(TimeStamp)
End Try
End Sub
This is just an example based on some code I altered from this at MSDN: Monitor.Enter Method[^]
Many thanks in advance!
modified on Tuesday, April 14, 2009 10:02 AM
|
|
|
|
|
Hi All,
Im looking for a free solution/approach to capturing video from a clients webcam and sending back the recorded video to my server (IIS).
Flash player, Javascript, silverlight, asp .net, etc..
Any Ideas?
Thanks
M
|
|
|
|
|
i am using sql server 2005 express and i have one web site which is i have published and installed on machine but when connecting to sql server 2005 express getting error login failed mycomname/ASPNet user why not taking user name insted of aspnet how do i login my con string is as follws
<add name="EMSConnectionString" connectionString="Data Source=.\sqlexpress ;Initial Catalog=EMS;intigrated security=true" providerName="System.Data.SqlClient"/>
|
|
|
|
|
nikhil1234 wrote: why not taking user name insted of aspnet how do i login my con string is as follws
<add name="EMSConnectionString" connectionstring="Data Source=.\sqlexpress ;Initial Catalog=EMS;intigrated security=true" providername="System.Data.SqlClient">
Your web application is running in the context of the ASPNET user. Therefore, when you use integrated security you will log in with the credentials of the user that your process is running as. This is the correct functionality.
You must grant the appropriate access to the ASPNET user to the database.
Possibly the reason you did not see this when you were developing the web site is that Visual Studio has its own built in Web Server that uses your credentials. When you deploy to IIS you use the credentials IIS uses.
|
|
|
|
|
intigrated security=true
integrated security=true
Try that.
var question = (_2b || !(_2b));
|
|
|
|
|
It is true by default, so that typo would likely have been ignored.
|
|
|
|
|
Fair enough, I probably should have read the question first, but that typo kinda blinded me straight on.
And thanks, I didn't know Integrated security was true by default.
var question = (_2b || !(_2b));
|
|
|
|
|
hi
function window.onunload()
{
if (window.event.clientX < 0 && window.event.clientY < 0)
{
//call Session.Abandon()
}
}
in above funcion i am check browser closed button is press or not when button is press i want to close the session just like a Session.Abandon()(server side function). and second question is my project above 200 web form are there and every page redirect to another page so how can i used above code only single time
|
|
|
|
|
You can do one thing
if(window.event.clientX < 0 && window.event.clientY <0)
{
window.open("CloseSession.aspx", "OpenWindow_Close_Session",'left=12000,top=1200,width=10,height=1');
}
In CloseSession.aspx Page Load Do the server side task and make it self.Close();
protected void Page_Load(object sender, EventArgs e)
{
Session.Abandon();
string strPopupScript = "<script language="javascript">self.close();</script>";
Page.ClientScript.RegisterStartupScript(typeof(Page), "PopUpScript", strPopupScript);
}
Hope this will help you.
cheers,
Abhijit
CodeProject MVP
|
|
|
|