0

I have a controller called Clients within that I have the CRUD actions as Actions [HttpPost]. Add, Update, Delete. All of this Actions is using RedirectionToAction. As shown on the screenshot below, I have tried both post and get

enter image description here

The only thing is that I'm not using the Begin form instead I'm using the old way as shown below.

enter image description here

The problem is that when I test it using the debug from Visual Studio it works. But when I deploy it to the Actual server (IIS) and test it I'm getting a 404 error.

Initially I didn't create a view for each Acton but even if I tried creating a view for each it still didn't work.

I have deploy the same code on my Home Virtual Server and it works. It looks like the issue is our work server. Any thing that cause this?

2
  • looks like your routes are not properly mapped outside of debug, have a look at your web.config Commented May 24, 2017 at 18:07
  • Hi @Louis, I'm new to MVC, is there a specific configuration I need to look for? Thanks. Commented May 24, 2017 at 21:26

1 Answer 1

1

sHTML.push("<form name='frmUpdateClient' method='POST' action='/Clients/Update'>");

Here you seem to have hardcoded the action parameter of the <form> element to /Clients/Update. But maybe on your production server you have hosted your ASP.NET MVC application in a virtual directory. So you might need to take that into account and generate the proper url:

action='/VirtualDirectoryName/Clients/Update'
Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Darin, What you said is correct. I put the VirtualDirectoryName and it works. My question is, is there a setting within web.config to achieve this without hard coding the Virtual DirectoryName?
No, there's no such setting. The proper way to do this is to use Url helpers to generate the action attribute of the form instead of hardcoding it because those helpers will take into account the virtual directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.