Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server side .net not working! Help needed! #8

Open
saz1942 opened this issue May 6, 2014 · 29 comments
Open

Server side .net not working! Help needed! #8

saz1942 opened this issue May 6, 2014 · 29 comments
Labels

Comments

@saz1942
Copy link

saz1942 commented May 6, 2014

Hi, I was trying to run the .net source that has been provided. I don't get any exceptions or error messages but still i'm not getting any data or map while running on my IIS. I have deployed the DB and .net source the way it is instructed.

I couldn't resolve the issue. I checked the connections string and all the connection configurations in web.config which is fine. I never worked on json. I also suspect map.js is not working properly. Can anyone please enlighten me or show me the way to resolve this issue. By the way, I downloaded the app from google play store and checked on your test page and that's working fine.

@nickfox
Copy link
Owner

nickfox commented May 6, 2014

Hi

Can you please give me the URL of the DisplayMap.aspx page that is not working.

thanks
Nick

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

Hi, Thanks for you response. Did you mean public url? If yes then i will let you know soon. I have a IIS server where i hosted that .net source. I don't think you can access that publicly. Let me see what i can provide you.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

Yes, I would need to access a public url to see what's wrong.

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

Hi Nick, here's the url: http://kingsapps.ca/GPSTracker/
Hopefully you can access this. The database has the data which you have provided with the .bak file. I guess it is supposed to load at least those data when the page loads.Please let me know if you have any queries. Thanks.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

When I try to access the following page:

http://kingsapps.ca/GPSTracker/GetRoutes.aspx

I get an empty response (except for the trailing json ] } which comes from the GetRoutes webpage.

are you sure that your connection string in the Web.config file is correct?

connectionString="Data Source=WINDOWS8-MBP\SQLEXPRESS;Initial Catalog=GPSTracker;Persist Security Info=True;User ID=sa;Password=gpstracker"/>

is the name of your database GPSTracker and is the sa password of your database gpstracker?

it's not getting the data from the DB.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

alos check the data source. WINDOWS8-MBP\SQLEXPRESS is for my machine.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

try this:

Data Source=localhost\SQLEXPRESS;

instead of:

Data Source=WINDOWS8-MBP\SQLEXPRESS;

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

You are right. it's not getting data from the DB. But I totally changed the connection string that i usually use. Which is.
connectionString="Data Source=[server ip];Initial Catalog=GPSTracker;Persist Security Info=True;User ID=xxx;Password=xxx"/>

Is there any more testing you want me to do?

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

and you are able to open the database and see the table?
you have hidden the user name and password in the string above. Did you add the new user permissions to the GPSTracker db?

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

I just checked using the grid view if it can access the database or not and found it shows the data while i am in local db but it doesn't pull data from the other sql server that i am suppose to use. Is it because of some access permission? But both the cases GetRoutes.aspx shows the same thing that you mentioned.
GetRoutes.aspx file contains below code:

using System;

public partial class GetRoutes : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// our helper class to get data
DbJsonReader reader = new DbJsonReader();

        Response.AppendHeader("Content-Type", "application/json");

        Response.Write(reader.getJsonString("prcGetRoutes", "routes"));
}

}

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

I also checked in another internal server. There i can see the data from the DB but GetRoutes.aspx still shows the same thing.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

Hey, can we please keep the conversation here and not split it off onto websmithing (too confusing to keep track). Try this from within Sql Server Management Studio. Open the GpsTracker database and on the toolbar, click "New Query" and execute the following code:

exec prcGetRoutes;

if this runs and returns data, then you know its a permission problem. If it does not return data, the make sure the table gpslocations has data in it.

@saz1942
Copy link
Author

saz1942 commented May 7, 2014

I'm sorry about that. You put a comment after mine so i thought i should reply that.

So i executed that stored procedure. At first place, it was showing a collation conflict. Then i made a little change in the procedure added COLLATE database_default around "=" operator in the query. After that it worked and was showing data on the map which i ran from my local server. I guess i need to check my public server for the permissions. Thanks so much for help. It would be really useful tool for me. I might bother you sometimes if any issue comes up.

@nickfox
Copy link
Owner

nickfox commented May 7, 2014

Ok, good. If you are getting data from that stored procedure then it's definitely a permission problem. Googling is going to be the best way to solve that problem. Let me know if you get entirely stuck again and also let me know if you get the whole thing working. Good luck with it.

n

@saz1942
Copy link
Author

saz1942 commented May 8, 2014

Thanks so much again. I will keep you posted.

@saz1942
Copy link
Author

saz1942 commented May 8, 2014

Hi Nick, Sorry to bother you again. I kinda stuck again while uploading the gps data. I used http://kingsapps.ca/GPSTracker/updatelocation.aspx as a up loader site but seems like database is not updating.Can you please give me a clue what's happening in here again? By the way i change my database server, Hopefully you can now access that url and see whats happening. Thanks in advance.

@nickfox
Copy link
Owner

nickfox commented May 8, 2014

This is a little bit trickier to deal with. The first thing you need to do is take a look at your IIS server logs. Google the location of the logs and then take a look at the access and error logs. That is the first step. Let me know what you find.

@saz1942
Copy link
Author

saz1942 commented May 9, 2014

I've gone through the logs but didn't find anything that might give me some clue. Everything looks fine to me. updatelocation supposed to be http post which should be on port 80 and also the status code is 200 which means successful. logs are like:

2014-05-09 12:34:01 192.168.1.1 POST /GPSTracker/updatelocation.aspx - 80 - 142.177.198.61 android-async-http/1.4.4+(http://loopj.com/android-async-http) 200 0 0 130

By the way, I used the correct upload website url, right? I have to use updatelocation.aspx, right?

@nickfox
Copy link
Owner

nickfox commented May 10, 2014

By the way, what's your name?

In a situation like this, we need to isolate the problem. We don't know if the problem is from the phone to the upload webpage or from the webpage to the database (or both), so we need to break it down. I am suspecting a permissions problem still so that is where I would start. Take a look at the upload webpage:

https://github.com/nickfox/GpsTracker/blob/master/servers/dotNet/UpdateLocation.aspx.cs

comment out lines 11 - 26 and in lines 35-46, fill in some fake values (make sure they are the correct format) and then submit that page. If it fails to update the db, we have isolated part of the problem. So do this for starters and see where the problem is.

n

@saz1942
Copy link
Author

saz1942 commented May 12, 2014

Hi, Sorry i was away this whole weekend. My name is Azam.
So I tried using your strategy but the result is the same.No data is uploading to the DB. Here's the code that you wanted me to do after commenting out.

protected void Page_Load(object sender, EventArgs e) {
//string latitude = Request.Form["latitude"];
//string longitude = Request.Form["longitude"];
//string speed = Request.Form["speed"];
//string direction = Request.Form["direction"];
//string distance = Request.Form["distance"];
//string date = Server.UrlDecode(Request.Form["date"]);

    //// convert to DateTime format
    //date = convertFromMySqlDate(date);

    //string locationMethod = Server.UrlDecode(Request.Form["locationmethod"]);
    //string phoneNumber = Request.Form["phonenumber"];
    //string sessionID = Request.Form["sessionid"];
    //string accuracy = Request.Form["accuracy"];
    //string eventType = Request.Form["eventtype"];
    //string extraInfo = Request.Form["extrainfo"];

    // our helper class to update the database
    DbWriter dbw = new DbWriter();

    try {

        // update the database with our GPS data from the phone
        dbw.updateDB("prcSaveGPSLocation",
            new SqlParameter("@latitude", 45.079369),
            new SqlParameter("@longitude", 2.350800),
            new SqlParameter("@speed", 0),
            new SqlParameter("@direction", 0),
            new SqlParameter("@distance", 0),
            new SqlParameter("@date", "2014-05-12 16:16:39"),
            new SqlParameter("@locationMethod", "android"),
            new SqlParameter("@phoneNumber", "542"),
            new SqlParameter("@sessionID", "1111"),
            new SqlParameter("@accuracy", 85),
            new SqlParameter("@eventType", "true"),
            new SqlParameter("@extraInfo", "valid"));
    }
    catch (Exception ex) {
        Response.Write(ex.Message);
    }
}

// convert to datetime string
private string convertFromMySqlDate(string date) {
    DateTime dt = DateTime.ParseExact(date, "yyyy-MM-dd HH:mm:ss",
    System.Globalization.CultureInfo.InvariantCulture);
    return dt.ToString();
}

But then I tried in a different way bypassing your helper class(DbWriter.cs). Just executed the stored procedure on a submit button after manually giving input using webform. It worked in this case. I didn't include my one cause its too long.

@nickfox
Copy link
Owner

nickfox commented May 12, 2014

Hey Azam, pleased to meet you.

Try this as a test. In your connection string, use the sa user and password. I'm pretty sure its a permissions problem. This will hopefully tell us if my thinking is correct.

And check out this tutorial on permissions.

http://www.codeproject.com/Articles/674930/Configuring-IIS-ASP-NET-and-SQL-Server

but first try the sa account and let me know if that fixes the problem (just for a test).

Nick

@saz1942
Copy link
Author

saz1942 commented May 12, 2014

Nice to meet you too! But in this testing what would be the data source if i use username and password as "sa"? Because with this username and password and same old data source is not giving me anything!

@nickfox
Copy link
Owner

nickfox commented May 12, 2014

like this?

connectionString="Server=localhost\SQLEXPRESS; Database=gpstracker; User Id=sa password=P@ssw0rd"

experiment a little.

http://stackoverflow.com/questions/5283727/what-is-the-sql-connection-string-i-need-to-use-to-access-localhost-sqlexpress-w

@saz1942
Copy link
Author

saz1942 commented May 12, 2014

The upload site i use is connected to a different server not the localhost. I also use sql server localdb as data source or server. But i guess the upload site that i can use in the android phone can't access that local db. Sorry may be i'm not understanding or little bit confused.

@saz1942
Copy link
Author

saz1942 commented May 13, 2014

Hi Nick, sa account didn't solve the problem. It doesn't even load the route.

I also checked the tutorial of IIS and SQL configurations and made few changes in mine. But still the problem is the same. The SQL server and IIS that I'm using for this is being used for few websites which are running totally fine.

Whenever i try to submit data from webforms directly to the DB using the stored procedure it works. I also tried your suggestion to submit fake values directly to the db. Like i said before it didn't work out. I tried few different ways using sqlcommand and sqlparameters. It just takes the text value from the webform inputs but it doesn't submit direct values or request.form(upload site used in client side) values to the DB. I'm wondering if you are getting any clue from this.

Do i have to look in to the client side code of android?

@nickfox
Copy link
Owner

nickfox commented May 13, 2014

I really don't think there is anything wrong with the code. I still think it's a permissions problem. Maybe within sql server. Check to see what the permissions are on all of the stored procedures. If you can't find a problem, then let's a schedule a time to skype. I would need to be able to control your desktop for a few minutes and it would have to be the machine that has access to the sql server and iis. First check the permissions on the procedures in the db.

n

@saz1942
Copy link
Author

saz1942 commented May 14, 2014

I checked the stored procedure and also added few extra permissions. But I don't see any changes yet. Just another thing I'm wondering, do i have to build or compile the client side android code? I just downloaded from google play store and saved my upload site on that. Hope that's as simple as that.

That would be great if you can schedule a skype meeting. But the problem is, I may not be able to give you the full access to sql server and iis. You can access the db using SQL Server Management studio from my desktop and also can see the server side .net codes but I might not be able to give you access to the server machine. But i will see what i can do.

By the way, what time zone are you in? I'm in Atlantic time zone. What time would be good for you? I prefer between 8am to 5pm ADT in weekdays.

@nickfox
Copy link
Owner

nickfox commented May 15, 2014

I'm near Seattle. Give me your skype name and I will send an invite. Those times work for me too.

@saz1942
Copy link
Author

saz1942 commented May 16, 2014

great. will talk soon then. here's the ID: sazib1942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants