Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 7-Mar-13 9:57am
Edited 7-Mar-13 21:27pm
v4
Comments
Zoltán Zörgő at 7-Mar-13 16:10pm
   
What is this for a title?!
Is it asp.net mvc?
m19anand at 7-Mar-13 23:56pm
   
sorry... yes it is asp.net mvc3
Jameel Moideen at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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/[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 341
1 Marcin Kozub 225
2 Praneet Nadkar 197
3 Sergey Alexandrovich Kryukov 190
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 8 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100