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 7929357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:02:52+00:00 2026-06-03T20:02:52+00:00

my site is hosted at IIS7.5 i have a controller action as below [HttpPost]

  • 0

my site is hosted at IIS7.5
i have a controller action as below

[HttpPost]
    public ActionResult Create(ClientDocument clientdocument,HttpPostedFileBase FilePath)
    {
        if (ModelState.IsValid)
        {
            try
            {
                if (FilePath != null && FilePath.ContentLength > 0)
                {
                    var filename = Path.GetFileName(FilePath.FileName);
                    string ext = filename.Split(char.Parse(".")).LastOrDefault();
                    clientdocument.FilePath = clientdocument.Title + "." + ext;
                    var path = Path.Combine(Server.MapPath("~/Uploads"), clientdocument.Title + "." + ext);
                    FilePath.SaveAs(path);
                    db.ClientDocuments.Add(clientdocument);
                    db.SaveChanges();
                    return RedirectToAction("../");
                }                    
            }
            catch(Exception ex)
            {
                return HttpNotFound("There Was A Problem Uploading File And Creating A Record");
            }
        }

        ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "FullName", clientdocument.ClientID);
        return View(clientdocument);
    }

when i click the button it tries to upload the file but then show following error message

http 404 file or directory not found
the resource you are looking for might have been removed,had its name changed or is temp unavailable

please assist how to configure iis7.5 to upload this file while in VS2010 every thing is working fine.

EDIT

After Changes @keshav Mentioned
View:

    @using (Html.BeginForm("Create", "ClientDocument", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
            <legend>Attach New Client Document</legend>
    <div class="editor-label">
                @Html.LabelFor(model => model.FilePath)
            </div>
            <div class="editor-field">
                <input type="file" id="FilePath" name="FilePath" />
                @Html.ValidationMessageFor(model => model.FilePath)
            </div>
   <fieldset>
}

and Controller:

[HttpPost,ActionName("Create")]
    public ActionResult Create(ClientDocument clientdocument,HttpPostedFileBase FilePath)
    {
        if (ModelState.IsValid)
        {
            try
            {
                if (FilePath != null && FilePath.ContentLength > 0)
                {
                    var filename = Path.GetFileName(FilePath.FileName);
                    string ext = filename.Split(char.Parse(".")).LastOrDefault();
                    clientdocument.FilePath = clientdocument.Title + "." + ext;
                    var path = Path.Combine(Server.MapPath("~/Uploads"), clientdocument.Title + "." + ext);
                    FilePath.SaveAs(path);
                    db.ClientDocuments.Add(clientdocument);
                    db.SaveChanges();
                    return RedirectToAction("Index", "Home");
                }                    
            }
            catch(Exception ex)
            {
                return HttpNotFound("There Was A Problem Uploading File And Creating A Record");
            }
        }

        ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "FullName", clientdocument.ClientID);
        return View(clientdocument);
    }

still i am having same problem as before.

  • 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-06-03T20:02:55+00:00Added an answer on June 3, 2026 at 8:02 pm

    As far as I know you shouldn’t have to change any settings in IIS…
    further to what @Darin Dimitrov said about the exception can you change the code in the catch clause to:

    catch(Exception ex)
    {
            ViewBag.errorMessage = ex.Message;
            return View("Error");
    }
    

    and in your error page (should have one under the shared view folder) add the following line

    @ViewBag.errorMessage
    

    I am thinking the code is throwing some exception on the server but not when you run it locally. This will help you narrow down problem. If you are still getting an 404 error then there probably is a setting issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a classic ASP site that is been hosted in IIS 7.5. I
I have a web site hosted on IIS with windows authentication. I am trying
I have a Magento 1.6.2 site hosted on 1&1. Because of certain installed extensions
Scenario : I have a PHP Forum and a Asp.Net site hosted on Linux
I have some images hosted on the Default Web Site on IIS 7 but
I have a asp.net mvc site that being hosted via IIS 7. I believe
I used to have a BlogEngine.net based blog, hosted in IIS7. Now I have
I have a WebForms application hosted in IIS 7. When I run the site
I have a WCF web service hosted in IIS7 which is reporting its endpoint
I have a site hosted on IIS6 server. All the pages with specific url

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.