Add KML to Google Maps by querying database in asp.net page - c#

I created an asp.net web page (C# .NET 4.5.1 web application) and added a google map to it that centers on the user's current location, adds a weather overlay, and all is working fine. As this is a solution for pilots I want to add their route for today. I have to query the database for today's routes and then put the KML data on the map. I'm not overly well versed in javascript or jquery as I'm learning this. I can create a method in the code behind that returns the KML and/or geocoords for today's route but I'm not sure how to get that to the google map.
If anyone could help in how to go about this I'd greatly appreciate it.
Thank you.

I ended up creating a .ashx script handler page that returns the KML and the URL to this page is set in the kml layer options. One note is that the location of this .ashx page has to allow anonymous access if your site is locked down to logged in users only.

Related

How can I retrieve data from a website to my winforms using C#

I am creating a form where I want to insert a data in text box and retrieve the rest of the data from the website where it has all the details of it.
Any guidance would be much appreciated.
I checked this question but its not helping me
How can I retrieve real time data from a website into c# winform app?.
,
I am new so I dont understand most of the part.
You can use WebBrowser from Toolbox or Selenium Drivers. I prefer Selenium, it allow me full web navigation, you can fill fields with it, can submit forms, can extract information from websites and everything about web automation.
As I understand you will some content to textbox and based on the content added you want to get data from website? If its correct then you need to write code in your WinForm application to hit web service/web API to retrieve the data. Here you can find code to hit the web service/web API https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client

how to show only part of other website in my site using c#

I am using maps from maps.nyc.gov. What i want to do is to show only map from this website in my own website.
Let say here is the sample URL:
http://maps.nyc.gov/doitt/nycitymap/?searchType=AddressSearch&addressNumber=498%20&street=7%20Avenue&borough=Manhattan
I only want to show map from this site in my website don't know how to do it.
I used iframe but it loads complete website.
We can also use maps from this site: Sample link:
http://www.oasisnyc.net/map.aspx?zoomto=lot:4004310027
Please Guide.
Thanks
Possible solution:
make an ajax call (of other technique), and only take part of the content you have retrieved on your site.
if only the map, then i think you need div tag mainCenter
Or ask if the have an API (like google maps)
i did this using CSS.
Made an iframe and loaded that site in iframe and wrapped the iframe with a div.
Set the size of the div to the size of part of website you want to show.

Making Dynamically Created ASP.net Page SEO Friendly

im starting the pseudo code of a new site, and want it to be as SEO friendly as possible.
the site i am creating is a booking agency site with c# and asp.net. essentially bands will register on the site with their availability and other info, and fill out their profile information with images etc. this info will be stored in a db.
creating this is not a problem, but i want the site to be a SEO friendly as possible.
I know google loves huge sites with great content. And all of these profile pages would be an excellent addition to my site for seo purposes. i also hear that google cannot see dynamically generated content when crawling a site.
i want to find a method of coding these pages, so google can see the content when it crawls them.
i need a pointer in the right direction for a solution for this. nothing is off limits - i will basically code my entire site around this principle, i just have no idea where to start looking for a solution. im not looking for a code solution, just what i should be researching to solve this issue.
Thanks in advance
i also hear that google cannot see dynamically generated content when crawling a site.
Google can see anything you can retrieve via http GET request (ie: there's a specific URL for it) and that someone either linked to or is listed in a published xml site map file.
To make sure that your profile pages fit this, you will want to make sure that profiles are all rendered via a single asp.net *.aspx file that determines which page is shown via a url parameter. Something that looks like this:
http://example.com/profiles.aspx?profile=SomeBandName
Now, you probably also want a friendly URL, that looks like this:
http://example.com/profiles/SomeBandName
To do that, you need to set up routing.
In order to crawl and index your pages by google or other search engine properly. Follow the following guidelines.
i: Page title must be precise and according to content available in page.
ii: Page url should be user friendly.
iii: Content is king (useful content)
iv: No ajax or javascript oriented way to load contents.
v: No flash or other media files. if exist must have description via alt tag.
vi: Create url sitemap of all static and dynamically generated contents.
vii: Submit sitemap to google and keep tracking how google crawl and index your pages.
fix issues contineously if google found via crawling.
In this way your most pages and content will be index properly and fastly.
I'd look into dynamic URL Rewriting.
Basically instead of having one page say http://localhost/Profile.aspx you'll have a bunch of simulated urls like
http://localhost/profiles/Band1
http://localhost/profiles/Band2
http://localhost/profiles/Band3
etc.
All of those will then map to back to the orgial profile.aspx page with a parameter so internally in your code it would look like http://localhost/Profile.aspx?Name=Band1, http://localhost/Profile.aspx?Name=Band2, etc
Basically your website appears to have a bunch of pages for each band but in reality they are all getting mapped back to the same asp.net page but have different parameters.
This is article I read about it some time back. http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
i also hear that google cannot see dynamically generated content when crawling a site.
you could create a sitemap.xml with the urls pointing to the dynamic profile pages. using google webmaster tools you can submit and monitor the crawling progress.
you may also create an index page or something similar ('browse by category' pages) that link to matching profile pages.
a reference for seo I regularly use is http://www.seomoz.org/learn-seo

Using ASP.NET MVC with Javascript Google Charts

I wish to use Google organisational chart within my ASP.NET MVC project. I am however finding it difficult to get my head around how this would fit into the MVC architecture.
The Javascript to generate the chart will be contained in the head of my file and as this data will reguarly change, it needs to dynamically be created. Can anyone give me any tips on where to begin with this?
take a look at this page. Scott Gu talks about Sections in MVC 3. I've used this before to create a section in the head tag to place script block/styles that apply to only one page, this gives you the freedom to use page specific script/styles without make your DOM a jumbled mess.

How to implement page counter for an existing ASP.NET web application

I am finding a good way to implement Page Counter Statistic for internal web application (so maybe I can not use Google Analytics to help me).
I want to find out which page in my web application that user does not visit anymore. So I can investigate the reason why there is no hit to that page. If it has a bug or that page is not necessary anymore.
The easy way that comes to mind is to add every page with some line of codes to update the page page view. But there are so many page in my web, so this will take a lot of time.
So is there any other way to make a simple web page statistic with minimize line of codes.
For more information
- Every user have to log in before using this web.
- There is session to store user's ID.
- I use .NET 1.1 as an environment and plan to migrate to .NET 2.0+ in the future.
- Page stat is not show on web, I just want the hit count and then analyze it.
Google Analytics is probably your best bet. Although your site is internal, Google Analytics will still work so long as you are able to hit their server from within your network. I've used it on intranet sites before without any issues.
You use ashx files and invoke it via markup (i.e. as a jquery invocation or as using an image tag) or you add an HTTP module. Both can be implemented without recompiling-- just adding one more .dll to the bin and editing the web.config. There is not enough space in this text box to give full justice to the steps necessary to write a http module or handler and a hit counter.

Categories