Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:51:53+00:00 2026-05-24T22:51:53+00:00

I’m working on my first ASP.NET MVC 3 application and one thing I need

  • 0

I’m working on my first ASP.NET MVC 3 application and one thing I need to do is handle some data that is exported from someone else’s system and turn around and import it, on user action, into the system and perform some error checking, etc. on it.

Here’s how I have attempted to solve this issue:

I’ve got a view with a div:

<div>
   <span><b>Recipe Data:</b>
     <input type="file" name="uploadFile" />
     <input type="submit" value="Load" />
   </span>
</div>

and that allows me to choose a file and then submit it. Then I’ve got a controller action that looks like this:

[HttpPost]
public ActionResult Index(HttpPostedFileBase uploadFile)
{
   try
   {
      // attempt to read the file
   }
   catch (Exception)
   {
      throw;
   }
}

So, when I’m using IE, I can examine the uploadFile parameter and it gives me a path like:

FileName:c:\\Users\\Matt\\Desktop\\TestFiles\\AppleBerry.xml

(which is exactly the full path to the file I picked)

But when I try the same thing in FireFox, that path is stripped off, so uploadFile.FileName is just AppleBerry.xml and the XDocument.Load tries to load it from:

C:\Program Files (x86)\Common files\Microsoft Shared\DevServer\10.0\AppleBerry.xml

So, I’m pretty sure that I’m going about this the wrong way and need some guidance. I need to read in that XML file, preferably via XDocument.Load() and then do some checks and eventually push the records in that XML file into a DB table. The only part I’m having issues with is this file path.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:51:53+00:00Added an answer on May 24, 2026 at 10:51 pm

    Try loading the file directly from the request stream and don’t rely on the FileName property because you haven’t saved the file on the server yet so it won’t find it:

    [HttpPost]
    public ActionResult Index(HttpPostedFileBase uploadFile)
    {
        if (uploadFile != null && uploadFile.ContentLength > 0)
        {
            try
            {
                // attempt to read the file
                var doc = XDocument.Load(uploadFile.InputStream);
                // TODO: do something with the XML document
            }
            catch (Exception)
            {
                // Make sure you do something more meaningful here
                // instead of rethrowing and erasing the stacktrace 
                throw;
            }
        }
        else
        {
            // The user didn't upload any file => take respective actions
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.