[RESOLVED]Calling APX page from .cshtml


I have an MVC application with some aspx pages in it.

One of the .cshtml file make calls to .aspx page, using the line below and this .cshtml file resides in App_code.

a href="@Href("~/a/b/c/MyPage.aspx?param1=" + @Id + "&param2=" +   @SomeId)">@Name</a>

This needs to be there because it has to be re-used as a partial class. So obviously since this .cshtm file is in app_code, it doesn’t have reference to HtmlHelper.

So when I make an Href call from there, the site.master is throwing null reference error on the below line, because @Html is null.

<li>@Html.ActionLink("Home", "Index", "Home"); </li>

The same master page works on other scenarios.

Can anyone suggest a work around.


Put your partial view in shared views. or do not use Helper methods. instead use

<li><a href="HomeIndex">Home</a></li>

If I move the partial view to Shared view. How do I access the method in the Partial View.

For example I have a method in partial view. Now this partial view is in the Views/Shared folder

like this.

Partial View name is Customer


@helper Render()



How can I access this method from another .cshtml.

When the partial view was in AppCode I could access it by saying @Customer. Now I cannot.

So the question is

How to make a call to a method is the partial view from another View.


I misunderstood your requirement.. Now I got it

check this link if it can helper


You can pass Html as parameter.

Leave a Reply