views:

52

answers:

2

i am using asp.net mvc 2.0. in that i am using partial views but whenever i clicked on particular link i get the follwing error

404 Not Found

can any one konw the solution the application run properly at local host but it shows the error when i uploaded on the server. thanks.

A: 

How did you generate the links? You should always use Html.ActionLink() or Url.Action() to generate links, to avoid problems when deploying.

For example, if you want to link to /Ctrl/Act/123 you should not use this:

<a href="/Crtl/Act/123">Here</a>

but this:

<%=Html.ActionLink("Here", "Act", "Ctrl", new { id = ""}, new {}) %>
Palantir
i am using<a href="#" onclick="LoadPartialView('#MainContentDiv', '/Home/ClickMe')">Click Me</a><br />
Renu123
So instead of "/Home/ClickMe" you should use Url.Action("ClickMe", "Home").
Palantir
i want to calll java script on onclick event for that reson i am using <a> tag
Renu123
<a href="#" onclick="LoadPartialView('#MainContentDiv', '<%=Url.Action("ClickMe", "Home")%>')">Click Me</a><br />
Palantir
than you so much its workin thank a lot
Renu123
So which answer are you accepting, mine or the one by powtac? You have accepted his, but you have commented the other way around... you can undo your acceptance still. You should accept the answer that was most helpful, not the first one you see... You should press the arrow up too.
Palantir
but i got another problem because of this my buttons are not working<input type="button" value="Add" onclick="LoadPartialViewPost('#MainContentDiv', '/Home/ProductPage/<%= (id=catId) %>', $('form').serialize())" />
Renu123
Same thing, you have a /Home/ProductPage/id url, you should replace it with a Url.Action call. Try with <%=Url.Action("ProductPage", "Home", new { id = catId})%>
Palantir
no its not working when button is on ascx page
Renu123
A: 

Check your servers error log. There must be 404 error details.

Open the network tab in FireBug reload the page and trigger the "wrong" request. And then check where the request goes to. FireBug catches all request a browser send.

powtac
error console is clear nothing is displyed
Renu123
When there is really nothing in the error log file, if could mean that your request is going fatally wrong to another url.
powtac
how can i get that wrong url because when i debug my application on local host it shows me correct url but when i upload it i get error.
Renu123
I dont know why. BUT: 1. your browser (javascript) says 404. 2. Your server does not recognizes the request. Conclusion: the request goes maybe to an other target.
powtac
any ways thanks for your help
Renu123