Click here to Skip to main content
15,882,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Im trying to access a view in other controller, consider im in payment controller, but im trying to use a partial view of welcome controller,...
public class welcomecontroler
{

 public action steps(model)
 {
 return view(model)
 }
}

public class payment{

 public action sample()
 {Model model = new Model();
  return partialview("~/Views/welcome/steps",model);
  
  //i tried all these ways
  
  //return partialview("../Views/welcome/steps",model);
  //return partialview("~/Views/welcome/steps.cshtml",model);
  //return partialview("~/Views/welcome/steps",model);
  //return partialview("../Views/welcome/steps.cshtml",model);
 }
}


what ever way i tried, its not hitting the welcome steps action,.... please do help me,..

Thanks in advance,
Anand
Posted
Updated 7-Mar-13 20:27pm
v4
Comments
Zoltán Zörgő 7-Mar-13 16:10pm    
What is this for a title?!
Is it asp.net mvc?
m19anand 7-Mar-13 23:56pm    
sorry... yes it is asp.net mvc3
Jameel VM 8-Mar-13 0:46am    
from where you are trying to call the Payment controller? in which view you want to render partialView?

1 solution

The logic a MVC is not conforming to what you desire.
A partial view is either shared between controllers, than you have to place it in the Shared folder; or it is shared between views of a single controller, than you can place it under controller's views. Please remember, that MVC is using conventions[^]. Please look at the following article: http://coding-in.net/mvc-3-organize-your-partial-views/[^].
But you can however influence the search paths. See following article: http://www.leonamarant.com/2011/02/17/adding-a-custom-directory-to-razor-view-engine-partial-view-locations-in-asp-net-mvc3/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900