Can't find shape files on server

4 posts, 0 answers
  1. Donna
    Donna avatar
    12 posts
    Member since:
    Dec 2010

    Posted 23 Feb 2011 Link to this post

    I'm having a problem when I try to use my map project on a shared server.  When I run it locally on my machine the following code works fine.

    private const string ShapeRelativeUriFormat = "DataSources/Geospatial/USA/{0}";
      
    public MainPage()
    {
         InitializeComponent();
         this.radMap.Provider = new OpenStreetMapProvider(MapMode.Aerial, true);
         this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
    }
      
    private void radMap_InitializeCompleted(object sender, EventArgs e)
    {
         if (!this.initialized)
         {
              this.initialized = true;
              this.SetupReaders(); 
         }
    }
      
    public void SetupReaders()
    {
         this.informationLayer.Reader = new MapShapeReader();
         this.informationLayer.Reader.PreviewReadCompleted += new PreviewReadShapesCompletedEventHandler(Reader_PreviewReadCompleted);
         this.informationLayer.Reader.Source = new Uri(string.Format(ShapeRelativeUriFormat, "usa_states"), UriKind.Relative);
    }
      
    private void Reader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
    {
          if (((MapShapeReader)sender).Source.ToString().Contains("usa_states"))
         {    
              if (eventArgs.Items != null)
              {
                     ....some logic here
              
         }
    }


     

    For some reason though, when I run the same exact code on the server it comes back with null within eventArgs.Items.  Its as though it is not finding the files?  I did see that eventArgs is also returning this error:

     

     

    The remote server returned an error: NotFound.
    Stack Trace: 
    at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
    at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
    at System.Net.WebClient.OpenReadAsyncCallback(IAsyncResult result)

     

     

    Any ideas on how I could resolve this issue?


     

     

     

     

  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 25 Feb 2011 Link to this post

    Hello Donna,

    It is very complicated and it is hard to reproduce the problem using just a code snippet you sent.
    Most often this problem occurs in published projects when MIME types for shape and dbf files are undefined on the web server. Please check that MIME types for using shape files are defined:
    Extensions: .shp and .dbf
    MIME type: application/octet-stream

    Also I would recommend to check that the files are accessible via HTTP on the server. For example you can try to download them using your web browser.

    Best wishes,
    Andrey Murzov
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Donna
    Donna avatar
    12 posts
    Member since:
    Dec 2010

    Posted 25 Feb 2011 Link to this post

    I added the MIME types to the IIS as:

    .shp    application/octet-stream
    .dbf     application/octet-stream

    Then I went to test to see if the files were accessible via http, and sure enough they aren't.  I couldn't open any of the .shp or .dbf files on the web browser.  Can you please tell me what I need to do to make these files accessible?
  5. Donna
    Donna avatar
    12 posts
    Member since:
    Dec 2010

    Posted 25 Feb 2011 Link to this post

    OK nevermind.  I was able to finally get it to work by changing the Build Action for the .dbf and .shp files to Content.

    Thanks for all your help.
Back to Top