Can anyone explain to me why this first example works fine but the second, which would use a little less code and in my mind appears to achieve the same result, yet throws a null ref error?
This works ...
if (Session["sid"] == null || Session["sid"].ToString() == "") { // session is NOT valid. } else { // session is valid. }
This does not work?
if (String.IsNullOrEmpty(Session["sid"].ToString())) { // session is NOT valid. } else { // session is valid. }
I have read that the best way to secure images from being access would be to place them into a database rather than into a file system or virtual directory. Is this correct? I am creating a site that needs to have the images the user upload be secure as possible. I initially programmed the images to be uploaded to a database then I reprogram the site to have them store in to a file system/virtual directory. I'm still up in the air in terms of which one to use. Again, security is my primary concern.
I have setup my business object to have a create_date and edit_date members both datetime datatypes. My company want to display the create_date and edit_date fields in a gridview for each transaction. The problem i have is that after insterting a record it will have a valid create_date but no edit_date and when displayed in the gridview it defaults to datetime.minvalue (My default). How on earth do i show an empty field in my gridview for a null datetime field in the database?
I am using similar architecture to the Imar Spaanjaars example of a tiered solution. With a few small tweeks it has worked well for me for ages. I am passing a List<Database> to my object datasource which connects to my gridview.
I am logged in as user1, and while creating a user in which I have additional information which would store first and last name into the profile database. I have the following code
[Code]....
But because I just have profile like that, it is updating the profile of user1 not the new user i just created
I use asp:Login control, user can login properly, but while checking user Profile information within LoggedIn event of Login control, all of the fields in the Profile objects are empty. Also, User.Identity.IsAuthenticated always returns false. But, all of these issue solved while navigating to another page. Why User.Identity.IsAuthenticated returns false, even user logged-in properly? And, is there any way to get user's profile information within LoggedIn event of Login control?
I'm having this very annoying issue.Trying to make ASP.NET profile work in my MVC2 application.This is the C# code:
[Code]....
Here is the web.config file:
[Code]....
And finally the controller action:
[Code]....
As soon as I submit the form I get an error. I can't even debug C# as the error occurs before stepping into public ActionResult Create(UserProfile model, string submitButton)...The error is:
Server Error in '/' Application.
Value cannot be null.Parameter name: username
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.Parameter name: username Source Error:
[Code]....
Stack Trace:
[Code]....
[ArgumentNullException: Value cannot be null. Parameter name: username] System.Web.Util.SecUtility.CheckParameter(String& param, Boolean checkForNull, Boolean checkIfEmpty, Boolean
i have a WebSite project which i published, in the machine where i published the WebSite everything works smooth. when i moving it to the server, i got the Error:
Value cannot be null.Parameter name: type
Description:
An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.Parameter name: type
I have a clear button and a textbox in an aspx page. I set the session variable in this page as
String str = Textbox1.Text;
Session["TypeIds"] = str;
and I clear the sessions in a clear button event as
Session["TypeIds"]=null;.
Then when the user types some value in the textbox ,on Response.Redirect on another aspx page, the session variable returns null values.It does not retain its session state. The session state has to be maintained in the next page. Is it because this clear button event and setting explicitly to null creates this problem?
On my development machine, the session state data is retained after a post back to the server. (XP VS 2008) (This is true if running from within VS or if running in browser with localhost.)On the deployed test server, the session state is blank in IE, but works in Firefox. (Svr 2003 IIS 6)Both machines are running the exact same code with the exact same imputs and same web.config. There is no code between the post backs that write to the session state.Newest addition to the server would be the consumption of a WCF web service. Could this be a symptom of something missing on the server(s) when trying to connect with WCF? I could not find any information other than installing the 3.0 framework. I have 3.5 SP1 installed on the test server.
I have a class library which has my LINQ doc in it. I added a stored procedure and I get the following in my .dbml.layout :
[Code]....
I include a reference to the dll of the class library to my web project and I get an error about value being returned as int where I am trying to put contents into a datalist or similar.
Code in class that calls this SP :
[Code]....
So I switched code to the following in my dbml.layout document :
I am looking for an elegant (i guess as elegant as it can be) solution to caching a users profile on login (whether it is session, cache, cookie, etc) and keeping it in sync when a users profile is changed. How do you guys handle this? Just simply call a Flush() method in your Save() method that invalidates the cache?
I am learning how to use profiles. My profile properties are defined in web.config and wish to add selected checkboxlist values to user profiles.TextBoxes and RadioButtonLists all seem to work fine, but not my CheckBoxList values.How do I go about making this work?
I have set the value of an int parameter to the attribute of a textbox.The textbox can be empty or null, how to check whether the parameter is empty or null?
This is probably something silly I'm missing but I'm definitely lost. I'm using .NET 4 RC and VS 2010. This is also my first attempt to use UpdateModel in .NET 4, but every time I call it, I get an exception saying Value cannont be null or empty. I've got a simple ViewModel called LogOnModel:
[Code]....
My view uses the new strongly typed helpers in MVC2 to generate a textbox for username and one for the password. When I look at FormCollection in my controller method, I see values for both coming through.
And last but not least, here's are post controller methods:
i've a songs website, where i'm adding items to cart for users who are logged in, but when a song is deleted from the website the users still have the cart info still intact, i'd like the songs in the cart also too be deleted when the song from the website is gone, how may i accomplish this ?
I have pass following SQL Query to the through ObjectDataSource
[Code]....
And I am passing parameter through QueryString and My idea is like when empty string is pass it should show me all records but when I am passing empty string ObjectDataSource is making NULL and I am not getting desire result
I have a form and stored procedure that inserts the data from the form. It works fine except that if a field isn't filled in it doesn't insert a NULL into sql it inserts "".
I've tried a few different ways but none seem to insert NULL, the one below still inserts "", can anyone point me in the right direction.
Here is the required part of the code, if you require more just let me know.
[code]....
So if I enter nothing into address1 field it should write NULL to screen but it always writes NOT NULL.
For coonverting Linq to DataTable I am using the following Extension Method(Taken from Stackoverflow)
L[code]....
The Extension Method creates XML file.But for null values no element is created in XML file.Say if Commission field is null then commission element is missing in Xml generation.
I want to insert element with empty string for null values (ref type) and (0.00) for decimals and (0) for integers. where do i need to make change?
How do I check if my value is empty AND Isnull? I need to check for both, using ISNULL is not enough because the data can change just so that it is empty.