Changing User In MVC 2 MockHttpContext Breaks Test?
May 26, 2010I changed the following line:
private readonly IPrincipal _user =
new GenericPrincipal(new GenericIdentity("someUser"), null /* roles */);
to
[code]...
I changed the following line:
private readonly IPrincipal _user =
new GenericPrincipal(new GenericIdentity("someUser"), null /* roles */);
to
[code]...
I have a GridView bound to a SqlDataSource with a default SelectCommand defined as such:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"
ConnectionString="<%$ ConnectionStrings:MyConn %>"
ProviderName="MySql.Data.MySqlClient"
SelectCommand="select * from blah blah" />
There are cases where I have to change this query dynamically at runtime, so I do the following:
SqlDataSource1.SelectCommand = sql; // 'sql' is the new query
GridView1.PageIndex = 0;
GridView1.EditIndex = -1;
GridView1.SelectedIndex = -1;
GridView1.DataBind();
updatePanel.Update();
This works just fine actually, but when I click the pagination controls, the result set defaults back to the SelectCommand defined in the SqlDataSource1.
I have a custom implementation of Application_PreRequestHandlerExecute which is applying a deflate/gzip filter to the response. However, on IIS7, this is failing on my "script generator" pages. These aspx pages take in Query String values and return a custom bit of script, changing the response type to text/javascript. I think it is failing because of the way iis7 uses mime types, but I'm unsure how to fix it short of turning all compressio off.
View 1 RepliesMy web.config is set up so that I don't have to change anything between deploy from UAT and Production. I can determine what machine it is running on and then programatically pick the correct connection string etc from the web.config based on the name.
Now we are adding a call to a web service which now causes us to have to make a change at deploy time. We set a "Region" flag in the web.config and then in coded an IF statement to call the appropriate webservice based on the flag so all we'd have to change is the "T" to a "P" when moving to production. But then hardcoding a web service in the application is not what we want to do. Nor do we want to change the web service address in the web.config.
Is there any way we can do something like the following to be able to not have to change the web.config at deploy?
It would be something like:
1. Grab current Machine name
2. Look in web.config for corresponding machine name web service reference (like we do for connection strings etc)
3. Use that web service in the processing.
im using asp.net for my webpage. im also using the login control too. i want it so when the user types in the correct user name and password, it redirects to a new page called test.aspx. i dont want to use login view.
View 2 RepliesI want to use C#/ASP.net to find out whether the user browsing the website is on the same network so that certain links are only displayed while in the office (to those who have access to them).
Anyone accessing from within the office will be doing so by going to it's local IP address (i.e. 192.168.x.x) whereas external users will be browsing to the public domain name.
All I need is some way to differentiate between the two types of user.
I have a TextBox, and I want to force the user to type an email format in this field like (example@mail.com) ?I don't want to use FilteredTextBoxExtender or the RegularExpressionValidator.
View 3 Repliesi have to do some message exchange with a 3rd party (in a website).When the client posts a page, i start the message exchange. When that doesn't succeed for some reason, i report this to the client by rendering the page with a message.On the background, in a separate thread, i start a process to send abort messages to the 3rd party. I can't do this while the user is waiting for the page to come back, because it might take a few minutes.But in a test project, the test ends when the message to the 3rd party is sent, and after the new thread is started. But it seems that the new thread also ends, when the test is done.
Is that normal behaviour?I do start the thread in a new class with a reference to 2 objects from the class which tries to send the message in the first place, may that be a problem?EDIT: it keeps running when the whole process is started in IIS
User1 logs in with "User1" as UserName with his password. After it, he fills some form and clicks on SAVE button. After it record saves successfully, but in LoginName control shows some another user name who already logs in, on another machine. [I have number of users]
I checked the web.config file.. The access permissions are defined properly... then what is the reason of it? Everytime User name is changing randonly. So that I am unable to genrate reports.
I am using profiles to store extra information about users. The thing that I want is that I am changing user name. But on the other side I have photo album gallery where I have stored the User name (Creator of album). These two tables (aspnet_Profiles and PhotoAlbum) are in different databases.
I have tried the following code while changing the user name
Private con As New SqlConnection(ConfigurationManager.ConnectionStrings("Photo").ConnectionString)
Dim updateSql As String = "UPDATE PhotoAlbum SET UserName = @UserName WHERE UserName = " & userName.Text
con.Open()
Dim myCommand As New SqlCommand(updateSql, con)
myCommand.Parameters.AddWithValue("@UserName", newUsername)
myCommand.ExecuteNonQuery()
con.Close()
Here newUserName is the new user name field and UserName is the previous name stored in PhotoAlbum table.
But it does not seems to work.On debugging it reports Invalid Column Name "userName"
How do I protect the url from a user changing one of the param/value pairs?
View 5 RepliesI am using the ASP.NET membership system and I have found the ability to 'add user to role' programtically, but I am wondering if there is a way of changing a user role?
I don't simply want to add a user to another role and I can't seem to find the 'remove user from role' command.
In my user control I got this inline CSS in which I have only css classes... like I am not setting any attribute or whatever on some ID..got only classes like :-
.sp
{
backgrond-image :url(blah blah);
}
and so on..
nothing of the sort
#id1
{
/* set some property here*/
}
Now my question:-
Do I need to worry about system generated IDs if the CSS in my user control got only classes ? like in my page source..the divs ID changes from their original ID to something like ctl00_ContentPlaceHolder2_ctl00_Banner_divBanner after adding usercontrol and master page ...
so changing IDs shouldn't make any difference..right ??
I have an update that changes user profile informationI have pulled the membership email in and can view the email in my table but it will not update the email when I change it.When I debug this code it seems to work fine and I beleive it was working before but suddenly stopped.I should add that I have created my own profile table and have had no problems updating all other information.Even adding the ability to update the membership password.here is my code for the update of the email:
[Code]....
Has anyone had a similar problem?I am not sure why it is not working
Our user is using integrated windows authentication.
All users hit the login page where they must login with their domain/username/password combination.
Once they login, they can change their password.
Once the password is changed, they are displayed a message and they can navigate through the rest of the site.
I get the following scenarios...
1) User can view one page but not a second page User changes password USer clicks on link and receives page USer clicks on second link and is asked for credentials
2) User can view all pages USer changes password User clicks on link and receives page User clicks on second link (and all links thereafter) and receives page (they are never prompted for credentials)
3) User can not view any pages
User changes password USer clicks on link and is asked for credentials
I wanted to be able, as an administrator, to create new users using the createuser wizard. When I use the wizard to add a new user, however, I end up logged in as that user, instead of as my admin account. How do I prevent from being logged in as the user I just created?
View 2 RepliesI am utilizing a LoginView control that is not changing its template after a user becomes authenticated.
This is from the master page where the control is used:
[Code]....
This is from the code behind:
[Code]....
I have a custom ascx user control on my page that includes a dropdownlist. There is an onSelectedIndexChanged event handler that is connected to this dropdownlist. The first time the user selects a value, the page does a postback and the logic executes correctly. However, if the user then goes to change their selection, the event handler does not get triggered.
View 3 RepliesI am having the language as English(unite states), on changing the language to English(United Kingdom) the date format is changed to dd/MM/yyyy.
but on using the date class in the asp.net application, this fetches the date format as the mm/dd/yyyy, which is the system date format.
but the logged in user date format is dd/mm/yyyy
so how to get the date format of the logged in user in asp.net applications.
I need to know how to change aspnetdb to store profile information unique to each user so that I can restrict records in an sql table to only show that user's records.
So if I make a "companyID" int, identity column where would I put it?
Also, when I write the where clause to companyID = profile (companyID) would that work?
I need to change a user's role in my application. Therefore I need to know the correct syntax in code behind to alter a user's role; i.e. string sql = "ALTER TABLE ...etc". I'm not sure how to implement this at all. Is it similar to the INSERT INTO query used in code behind, where we define the parameters etc?
View 2 RepliesI have a simple user control(.ascx) with a asp label inside of it. Using the codebehind(C#) from a aspx page, how can I change the text of that label? I have tried using public classes in my user control and a few other things that I could think of off the top of my head. Can somebody give me a quick example of how this would be done?
View 4 RepliesI am doing Automated coded ui testing in asp.net 2010 for web application. I am testing site and i need to know how can i create the test which will work with all browsers. Right now i created test in IE 8 but its not working in Firefox. So is there any way i can create one test and will work in all browser.
View 2 RepliesI am having a problem with security in a web application I am building using Visual Web Developer 2008. I am using Forms Authentication:
<authentication mode="Forms">
<forms name=".MYAUTH" timeout="20" enableCrossAppRedirects="true" />
</authentication>
And a SQL Server database with ASP.NET Membership and Roles. I am using the LoginView control with the AnonymousTemplate and LoggedInTemplate to manage the user's interaction with logging in and out. The problem I am having is that I am authenticating the user against the database:
If Membership.ValidateUser(_userName, _txtLoginPass.Text)
Then returns True and:
FormsAuthentication.SetAuthCookie(_userName, False)
sets the cookie correctly:
FormsAuthentication.Decrypt(FormsAuthentication.GetAuthCookie(_userName, False).Values(0))
{System.Web.Security.FormsAuthenticationTicket} CookiePath: "/"
Expiration: #1/21/2010 1:42:27 PM#
Expired: False
IsPersistent: False
IssueDate: #1/21/2010 1:22:27 PM#
Name: "jaymo "
UserData: ""
Version: 2
but when I check
HttpContext.Current.User.Identity.IsAuthenticated it always returns False.
If done this before and it worked fine. I cannot find any mistake I might have made or where something might have changed between ASP.NET 2.0 and 3.5.
The problem is when am assigning my session table value to newly created table and if now am changing any coloumn name then the session table value also changing.
But my question is am assigning Session value to newly created table so how should session value should be affected?
for refference in my application
sessionState
mode="InProc"