|
Hi vuyiswa,
Thanks for giving so much time i reading this and giving the reply.
You wrote :
Now i have deployed my website on IIS also and when i browse my page i can see it on the browser but ....... I am not able to connect to the database tables as when i enter the login and password it comes to the same login page again without showing any error. Now, I cannot identify whether its due to the following reason:-
How do you know that you cant connect , if you cant see the error ?
Because when i enter hte username and password that there in the database table User_Master[that has been converted to dbo.User_Master] , i cannot loog on to. Inspite it redirects me to the locgin page again.
Also I cannot debug the prog as i dont have VS 2008.
To check this whats happening , i tried one thing:-
On login page [in coding,aspx.cs page], i commented the line which checks whether the username and password is valid or not [ which fetches data from the database] and simply redirected to the Homepage.aspx. It works fine.
On one page [in coding,aspx.cs page], i commented the line which checks whether the session for userlogin is there or not[in login page if the user is authenticated i have saved his username in session and checked this session on everypage , if the session is not null then only user can see that page]. So now when i browse that page through IIS server the page is opening(ofcourse, it will) i enter all the data in the text fields. When i submit the button [which enters the data to the tables] it gives me that dirty yellow page. [as i said earlier i cannot debug the programme without VS or there is any way]
You wrote :
Now i have deployed my website on IIS also and when i browse my page i can see it on the browser but ....... I am not able to connect to the database tables as when i enter the login and password it comes to the same login page again without showing any error. Now, I cannot identify whether its due to the following reason:-
How do you know that you cant connect , if you cant see the error ?
Because if it connects then there is some problem related with database, and if there is some problem with database then i have redirected it to the Error.aspx page.
You wrote :
2> I have to make some changes in the connectivity[in web.config or some other location]
what is your Question Regarding this ?
As now i am not using the default D/B provided by the VS2008 and using SQL Server 2005 express edition, so are there any changes in the connectin strings or how to attach the database to the websie.[In visual studio we just attach the database through that wizrd and give the path to the connection string.]
Thanks
|
|
|
|
|
I don't think problem with db connections.... if u think so try to install Fx SDK and debug ur code using CLR Debugger or else write a single test page with complete diagnostic.
|
|
|
|
|
hi Murugesan,
thanks for ur response but can u just explain the points that i made in the previous quote.
also there are many Fx SDK versions available like Java win SDK....which to download and install and is it free? as for rules cannot install the licensed version.
What do you mean by
write a single test page with complete diagnostic.
Thanks.
|
|
|
|
|
.Net framework SDK, which is free and download it from SDK Link
write a single test page with complete diagnostic.
For isolating the problem write a server side page to connect database.
|
|
|
|
|
hi ,
how to connect to the database and how to provide the GUI as I said that i dont have VS.
Please cant u favour me just give me some hint for login only ...
also below please find my login coding...
login.aspx.cs
protected void btnLogin_Click(object sender, EventArgs e)<br />
{<br />
if (Session["Admin"] != null)<br />
{<br />
if (txtPassword.Text.ToUpper.Equals(Session["Admin"]))<br />
Response.Redirect("Homepage.aspx");<br />
}<br />
String except = null;<br />
<big>DataValidation dv = new DataValidation();</big> String pass = txtPassword.Text;<br />
<br />
String password = null;<br />
<br />
password = dv.loginIn(txtUserName.Text);<br />
<br />
if (password==null)<br />
{<br />
Session["SourceFile"] = Formname;<br />
Response.Redirect("Error.aspx");<br />
txtUserName.Text = "Exception";<br />
}<br />
<br />
else if (password.Equals(pass))<br />
{<br />
Session["User"] = txtUserName.Text;<br />
if (Session["User"].ToString().ToUpper().Equals("ADMIN"))<br />
Session["Admin"] = "ADMIN";<br />
Response.Redirect("Homepage.aspx");<br />
<br />
}<br />
<br />
else <br />
{<br />
lblCheck.Text="Invalid UserName or Password";<br />
}<br />
<br />
<br />
<br />
}
the DataValidation function[this is one .cs file i have maintained for data validation]
public String loginIn(String userName)<br />
{<br />
String queryBuilder;<br />
<br />
{<br />
DataBaseConnection ds = new DataBaseConnection();<br />
<br />
queryBuilder = "SELECT Password FROM User_Master WHERE UserName = @uname";<br />
<br />
String pass = ds.loginDataBase(userName, queryBuilder);<br />
<br />
return pass;<br />
}<br />
<br />
}
the DataBase connection function
SqlConnection getConnection()<br />
{<br />
SqlConnection cn = null; <br />
{<br />
cn = new SqlConnection(); <br />
cn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();<br />
return cn; <br />
}<br />
}<br />
<br />
<br />
<br />
public String loginDataBase(String userName, String queryBuilder)<br />
{<br />
SqlConnection sqlcon = null;<br />
try<br />
{<br />
sqlcon = new SqlConnection();<br />
sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();<br />
sqlcon.Open();<br />
<br />
SqlCommand cmd = new SqlCommand();<br />
<br />
cmd.CommandText = queryBuilder;<br />
cmd.CommandType = CommandType.Text;<br />
cmd.Connection = sqlcon;<br />
<br />
cmd.Parameters.AddWithValue("@uname", userName); <br />
<br />
SqlDataReader dr = cmd.ExecuteReader();<br />
if (dr.HasRows == true)<br />
{<br />
dr.Read();<br />
return dr[0].ToString();<br />
}<br />
else<br />
return null;<br />
<br />
}<br />
<br />
catch (Exception ex)<br />
{<br />
return null;<br />
}<br />
finally<br />
{<br />
sqlcon.Close();<br />
}<br />
}
|
|
|
|
|
Try to throw an exception and see the message... if ur not getting any exception then simply check the database table has rows or not.
catch (Exception ex)
{
throw;
}
|
|
|
|
|
hey u deleted your mail ID ,
i have to mail u that code ,
and i have used that exception, i am redirecting to Error.aspx if any error comes.
you once again give me ur mail id
thanks
|
|
|
|
|
|
Hi All,
I have a .net class library which makes call to a web service. I am trying to write unit tests (methods) for the methods of that class library. But the test methods are giving exceptions. Like the code is not ready or some thing like that. But when I call those methods from a asp.net web page all the methods are giving correct values. Means the class library is able to connect to the web service and executing it methods.
The exceptions that the test methods are saying is, "the proxy is not ready", I have added that web service by using "Add Web References". And one more thing is, I dont have "WSDL" utility in my machine so I coulnt create the proxy and I have added the web service using "Add Web References".
Can anybody help me in resolving the issue. Any help or any link or any advice is greatfull.
Thanks in advance.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
First, what you are doing isn't really unit testing, it is integration testing (as long as your architecture is good), but you can use unit tests to exercise this.
I actually don't recognise the actual error you give - is it the actual message? I'm assuming the error is with the proxy accessing the server.
First: Is your test config pointing at the server?
Second: Is your sevice running under the web server built into Visual Studio: http://stevennagy.spaces.live.com/blog/cns!B2EFDBF0964586B3!198.entry?sa=436582379[^] If so, when you run your unit tests the server isn't necessarily running - and this might cause your problem ().
As for the wsdl.exe - it should be installed alongside VS, it is part of the .Net Framework Tools[^]. That said, I've used a web reference in the past without any problems.
If you give the actual error text, you'll have more chance of getting an answer.
|
|
|
|
|
Hi,
I will explain what I am doing again
I have a class library called DataAccess, this clas library is accesing few web methods. I need to test the methods of the class library "DataAccess". If I remove the web servcie call from the "DataAccesss" class library then Unit tests are working fine. But When I keep the Web service call in the method and run the unit test its giving the following error.
"Test method HireXpress.DataAccess.Test.LawLogicDataAccessClassTest.WS_SubmitNewHireTest threw exception: System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required..
at System.Net.HttpWebRequest.GetRequestStream(ref TransportContext context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at HireXpress.DataAccess.gaurdianservice.Guardian.WS_SubmitNewHire(Int32 inComKey, String inComPW, String[] inEmpData, ref String outResultMsg) in Reference.cs: line 149
at HireXpress.DataAccess.LawLogic.LawLogicDataAccessClass.WS_SubmitNewHire(ref String outResultMsg, Int32 inComKey, String inComPW, String[] inEmpData) in LawLogicDataAccessClass.cs: line 15
at HireXpress.DataAccess.Test.LawLogicDataAccessClassTest.WS_SubmitNewHireTest() in LawLogicDataAccessClassTest.cs: line 140"
Please help me in resolving it, I am struck here. Pls help me.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
OK, this is a very different error to the one in the OP. The key line in the stack trace is:
indian143 wrote: System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required..
For some reason the proxy is configured in such a way that it needs web-proxy access to get to the web-service sever (effectively the web service is not logged into a web-proxy server).
1. Check the config file in your test project. Make sure it points to the correct service address, this is the likely source of the error. If the server is local, it almost certainly doesn't need a web proxy set up.
2. Ensure your hosts file maps localhost to 127.0.0.1
3. If your service sits on a different IP to the client but on the same network, make sure that you configure the proxy access in IE to bypass for the destination address
4. If you genuinely need to supply a proxy service (i.e. your security policy forbids access to the destination address without logging in to the proxy) you will need to configure proxy login.
Without knowing your network setup it is difficult to help more, not only that I'm off to bed (1am here). Hope this helps[edit] - my post helping I mean, not the fact I'm off to bed!
|
|
|
|
|
Hi Keith,
Thanks for your support, which country are you in now .
Yeah I too came to a conclusion that it is might be because of security set up. One more question I have is "Do I have to set any properties at the time of Web Referencing?". Because it is clear that they are using https means secured socket layer. Do I need to make any settings at the time of creating Web Reference. If so can you please let me know those things.
Thanks once again for the sort of support you are giving me. Thanks a lot may God bless you in all corners your of life.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
indian143 wrote: Thanks for your support, which country are you in now
No problem, people join here to do this. I'm living in Jordan right now, I'm part developer part uni lecturer.
indian143 wrote: Do I have to set any properties at the time of Web Referencing
Not at the time of referencing, but you will have to do extra work at the time you consume the service if you need to provide security information. I'm afraid it has been a long time since I've used vanilla Web Services (I moved everything to WCF as soon as I could, my last asmx work was in 2006) so my memory is very sketchy about all this, and the framework will have moved on as well. My memory seems to be faulty, I would have sworn that you set up security credentials for the client in the web/app config (this is the case with WCF), but I couldn't find this for web services anywhere.
Anyway I did a bit of digging here are two pages that might be of use:
http://geekswithblogs.net/mnf/articles/108602.aspx[^]
Connect to a web service through a Proxy Server[^]
Hope they help!
|
|
|
|
|
WSDL.EXE gets installed when you install either a Visual Studio edition other than Express, or a Windows SDK (which are freely downloadable).
|
|
|
|
|
I dont have admin privileges, they would ask for the reason to give admin privileges. Cant I run the unit test cases if I dont have WSDL.exe or proxy. I think in Web references also VS.Net would cerate a proxy. Thats what references may be. But the web service call is not hitting the method in in the reference.cs file.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
you are right, WSDL.exe seems to require admin rights no matter what you want it to do for you, which doesn't make much sense to me.
|
|
|
|
|
You don't need to generate the proxy using WSDL directly, the web reference should just work. If you have proxy classes available this is proof.
Your "restricted" environment is could well be causing your problem- see my reply to your post: For some reason the client is trying to connect to the service via a web proxy that it has no authorisation for.
|
|
|
|
|
Hi,
In VS.Net IDE, if I am in a particular .cs or .aspx file in a particular project considering that application or solution is having lot of projects included in it. Now I want to know is there any short cut key to see that particular branch or project. Because its making me lot of problem, I am getting that particular project by saying my file as save as then seeing whole path and then going to that particular project.
Is there any short cut key to go to that project directly without doing all these things. Like If we want to go to the previous visited line in VS IDE press Ctrl+hyphen. Like this I want to know how to go to the project directly in the solution explorer using any short cut keys.
Thanks in advance.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Been doing C# for years - but this is the first time I've needed to do a web app so I'm trying ASP.NET for the first time.
I have a listview bound to a SqlDataSource. My SelectCommand needs to be something like "SELECT .... FROM ... WHERE Field LIKE '%value%'
I have ControlParameter tied to a textbox that will be the value used in the LIKE clause.
Here is my question:
If I code my SelectCommand to look like ......WHERE Field LIKE '%' + @value + '%'
It works, but if somebody types a value like O'Hara into the text box - it will choke due to the concatenation (and I'm pretty sure open me up to SQL injection attacks)
If I code my SelectCommand to look like ......WHERE Field LIKE @value
It will work perfectly if I manually type the % signs in the text box for value. Including if I type %O'Hara% (the single quote no longer chokes it since I'm not concatenating anymore) - but obviously I don't want to have to teach the world to always put % sings at the start and end of their search strings on my web site.
So what is the best place to concatenate the % signs at the start and end of my search string?
This must be a VERY VERY COMMON thing to do. What are others doing about this?
|
|
|
|
|
Figmo2 wrote: I have ControlParameter tied to a textbox
Instead, tie parameter to a string variable. Set the string variable to the value of the text box, and then replace every singe ' with '' (ie escape out the single quotes in the input criteria. You can thyen use WHERE Field LIKE '%' + @value + '%' without exposing yourself to any injection attacks.
|
|
|
|
|
|
Figmo2 wrote: If I code my SelectCommand to look like ......WHERE Field LIKE @value It will work perfectly if I manually type the % signs in the text box for value. Including if I type %O'Hara% (the single quote no longer chokes it since I'm not concatenating anymore) - but obviously I don't want to have to teach the world to always put % sings at the start and end of their search strings on my web site.
I think this is correct functionality, it is looking for records where Field contains "%....%" rather than "....". I don't see the need to manually type the "%" in the majority of cases, it'll just confuse most [non-technical] users. Do you need to use wildcards?
|
|
|
|
|
Great suggestions all - thank you. What I ended up doing was a little different. I think elegant, but maybe not. Open to critiques...
I left the ControlParameter tied to my text box. (the parameter is called @SearchExpr)
My WHERE clause in the SelectCommand is simply "...WHERE Field LIKE @SearchExpr..." (no concatenation, thus no problems with single quotes needing to be escaped)
And added an event handler for SqlDataSource.Selecting that does this...
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)<br />
{<br />
e.Command.Parameters["@SearchExpr"].Value = "%" + e.Command.Parameters["@SearchExpr"].Value + "%";<br />
}
So now the user just enters ANY search string into the text box (e.g. "O'Hara")
This is passed to the SelectCommand as a parameter, thus it is not executable code - so no worries about SQL injection (I think)
And then, in the event handler, right before the SelectCommand is applied to the SqlDataSource, I modify the value to add the % signs front and back.
It works like a charm but the only thing I am not certain of is how well protected I am against injection attacks. Am I right in assuming that this should be adequate protection?
|
|
|
|
|
Figmo2 wrote: Am I right in assuming that this should be adequate protection?
You're using a parameterised query, so you should be OK on that front. However, take a look at http://msdn.microsoft.com/en-us/library/ms179859.aspx[^] for some more "magic characters" that might appear in your search string, and give unexpected results.
|
|
|
|