MVC :: Razor Viewengine Breaks Actionfilter When Renderaction Is Used

Dec 17, 2010

I am using Actionfilter to globally filter our HTML comments from all action methods and in all controllers. It simply overrides OnActionExecuting and runs the response through a regex to filter the comments. I am also using RenderAction to render some more complicated widgets in my website. There is no caching in place, I just use Renderactionto keep my code as simple possible.

When calling RenderAction from within a Razor View, I get an error message telling me that "Filtering is not allowed". The problem does not occur when calling RenderAction from within an aspx View. It only occurs when calling RenderAction from within a Razor View. In case it matters: the view being rendered is implemented with ASPX. Is this a bug or a known limitation?

View 6 Replies


Similar Messages:

MVC :: Upgrade An 3 Project With Aspx Viewengine To Razor Viewengine

Jan 18, 2011

I have upgraded my MVC2 project to MVC3 project and now I want to change the viewengine from standard aspx to the Razor viewengine. I have tested to create a new MVC3 project with the Razor viewengine and this works just fine, but now I want to uppgrade my existing MVC3 aspx viewengine project to a project with the Razor viewengine.

View 17 Replies

MVC :: Where Does The EditorTemplates Go In Razor Viewengine

Nov 24, 2010

I've just installed the new MVC3 RC ,and have no idea about where the *.ascx template stuffs live in?

View 1 Replies

Dynamic Attribute Value In MVC 3 With Razor Viewengine

Jan 18, 2011

how i can write

<input type="checkbox" name="@var.ID"/>

if i use it it never work. how i can done it. it's render as well as i write in code. it's not worked as well scottgu define in their blog

View 2 Replies

Implement For Each Delegate In Razor Viewengine?

Feb 22, 2011

The following code works for webform view engine.

<% Model.Categories.ForEach(x => { %>
<li><a href="#">@x.Name</a></li>
<% }) %>

I wrote the above code as below in razor view:

@Model.Categories.ForEach(x => {
<li><a href="#">@x.Name</a></li>
})

But this doesn't work. Is there any way to achieve this in razor view?

View 2 Replies

Make A Section Optional With The Mvc Razor ViewEngine?

Feb 4, 2011

I have a Page.cshtml similar to the following (that does not work):

@{
Layout = "../Shared/Layouts/_Layout.cshtml";
var mycollection = (ViewBag.TheCollection as IQueryable<MyCollectionType>);
}
<h2>@ViewBag.Title</h2>

content here

@if (mycollection != null && mycollection.Count() > 0)
{
@section ContentRight
{
<h2>
Stuff
</h2>
<ul class="stuff">
@foreach (MyCollectionType item in mycollection )
{
<li class="stuff-item">@item.Name</li>
}
</ul>
}
}

As I said, this does not work. I want to not define the section if there's nothing in the collection. Is there any way to have something like this work? If not, what are my other options? I'm very new to this Razor ViewEngine. Edit In my layout i have:

@if(IsSectionDefined("ContentRight"))
{
<div class="right">
RenderSection("ContentRight")
</div>
}

what i don't want is the div to output when the section is empty.

View 2 Replies

Razor ViewEngine - Escape The "@" Symbol?

Mar 13, 2011

I'm trying to output some Twitter handles in ASP.NET MVC3 in conjunction with the Twitter @Anywhere API, and I haven't been able to figure out how to actually escape the "@" symbol in a Razor view. Does anyone know what the syntax is for escaping the "@" character in Razor? I've tried using <text></text> and that results in a JIT error.

View 2 Replies

MVC :: RenderAction() Ignores Model Validation, RenderAction() Does Not?

Jun 4, 2010

I'm using MVC 2 and MVC Futures 2.0.50217.0.

I started with a view which repeatedly calls RenderAction(...) to include some external content implemented by another controller in my application. This is from the containing view:

[Code]....

The subModel objects are instances of the model for the MyController.MyAction view which has some Data Annotations validation attributes upon it. MyController.MyAction checks the model state is valid before it renders its view and chooses a view appropriately. This works fine.

However, if I use the MVC Futures' strongly typed helper to call RenderAction like so:

[Code]....

...then the validation is not performed. Or at least, the model state does not indicate that the model is invalid.

View 7 Replies

Stop Continuation Of ASP MVC ActionFilter?

Mar 18, 2010

I have two custom ActionFilters on an action. In first of the actionfilters, I have an redirect performed if a condition is not met (classic authorization). And in another I have an redirect performed if another condition is not met (say role checking). But I do not want to continue to the second actionFilter if the first one is not met. How to do this?

View 1 Replies

MVC :: ActionFilter Returning To View On Handled Error

Oct 13, 2010

I have a action filter:

[Code]....

Once the action filter handles the validation, instead of redirecting to another pages is it possible just to return the view associated with the action with the updated modelstate? Basically this is to handle business validation exceptions thrown by the business layer in a generic way.

View 2 Replies

Abort/cancel Action And Response From ActionFilter?

Mar 3, 2011

Best way to abort/cancel action from ActionFilter

I've got this ActionFilter, and it's suppose to end the connection immediately and return a 401 Unauthroized:

public class SignInRequired : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)[code]....

I learned how you can cancel the action from executing by setting 'context.Result = new EmptyResult()` here, but I'm not sure if this is the best way to flush the response and close the connection.

View 1 Replies

C# - ViewData Set In An ActionFilter Is Coming Out Null On Master Page MVC3?

Feb 15, 2011

My Original Issue here:Help! I've got repository access in my MVC master page! Refactor time!What originated as a re factoring job to improve performance has revealed new issues. If I should keep this in my original question - feel free to delete this one, and rename the old one to something more relevant. I'm using an ActionFilter applied to a base controller to load some user-customized settings. My issue is that I save these settings in the filterContext.Controller.ViewData object but its coming through as null on my master page. Here is the relevant code:

Action Filter
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class StoreSettingsActionFilter : ActionFilterAttribute

[code]...

View 1 Replies

MVC :: ActionFilter For Banned Users Causes Error 'Server Cannot Modify Cookies After HTTP Headers Have?

Mar 12, 2011

I am trying to make ActionFilter which redirects banned users to /Error/NoAccess site, so I have ActionFilter:

[Code]....

Before each public class xxxxxxController : Controller I use [NoBannedUsersActionFilter]. But for example on website /Account/LogOff I have error: 'Server cannot modify cookies after HTTP headers have been sent.' and VisualStudio shows me AccountModel.css file and this method:

[Code]....

View 3 Replies

MVC :: Creating A Custom ViewEngine

Jan 15, 2011

I am woking on a MVC project which require me to put all controllers, models and views into a folder called Mvc instead of the project root, I created a custom viewengine, here is the code:

[Code]....

My Application_Start:

[Code]....

It does not work, when I request [URL], I got: The view 'Index' or its master could not be found. The following locations were searched:

~/Mvc/Views/Index.aspx
~/Mvc/Views/Index.ascx
~/Mvc/Views/Shared/Index.aspx
~/Mvc/Views/Shared/Index.ascx

I expect the custom viewengine to find the view at: ~/Mvc/Views/Home/Index.aspx

View 1 Replies

MVC :: Bind Method To Viewengine At Runtime

Apr 29, 2010

I've read about how I can create a custom viewengine however is it possible to load an assembly which has a method decorated by my own custom attribute say..[RenderWithView], then I dynamically invoke that method and apply a view engine to it, finally returning the html?

View 3 Replies

MVC :: Extending The RazorViewEngine For Custom ViewEngine?

Dec 9, 2010

I were following the tutorial at this page of how to build my own view engine: [URL] And in hope of just extending the existing RazorViewEngine I made some changes to the code in the tutorial...

[Code]....

The thing is that now when I run my site..I get the following error: CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?) and I just cant find a way to solve this..I have added the references.

View 4 Replies

C# - Viewengine Not Looking Into Areas For Views In Mvc3 Upgrade?

Mar 10, 2011

i'm upgrading my asp.net mvc app to the MVC 3 from mvc 2. I had everything set up so that there were no areas, but now i have to move the old application into its own area so i can start a new one. The new area is working great, but for some reason, when i try to go into the area where the old app was, it looks for the views to be in the views folder in the root of the app, instead of in the views folder in the area.

View 2 Replies

MVC ViewEngine ViewLocationCache.GetViewLocation Returns Null?

Jan 24, 2010

I am following Chris Pietschmann's solution for theming in ASP.NET MVC.

One thing I have noticed is that the view name is not being retrieved from the ViewLocationCache on subsequent requests. I am using ASP.NET MVC 2.0 RC

When the following code is executed:

this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);

and I hover over this.ViewLocationCache it just returns {System.Web.Mvc.NullViewLocationCache} - suggesting nothing was added?

View 1 Replies

MVC :: OutputCache / RenderAction And SEO?

Jan 29, 2010

I read many posts about outputcaching element in asp .net MVC, but i have one question.My architecture is :1 master page, 1 page (especially news information), and a few other controls like LogOnUser / Fixed status bar etc...I want to have my news cached cause there are three query to entities, but i need too the title for SEO of my master page (title is included in a contentplaceholder in master).I tried to use renderaction outputcache but it is not possible to retrieve the title from the renderaction. Have you any idea about this problem ?Maybe it's preferable to use a general outputcache and use a substitute from dynamic data, but i don't know if it's a best practice or not.

View 1 Replies

MVC :: How To Cache RenderAction

Jan 25, 2010

This one doesn't work while caching renderaction returned result.

<OutputCache(CacheProfile:="ProfileCacheName")> _
Function About()
Return DateTime.Now

[code]...

View 1 Replies

MVC 2.0 - Difference Between RenderPartial And RenderAction

Oct 19, 2010

I am trying to understand the difference between a RenderPartial and RenderAction. I guess that RenderPartial is like a UserControl and RenderAction is like a server-side include.

View 3 Replies

MVC :: Exception Handling With RenderAction?

Feb 24, 2010

We are using renderaction provided by MVC futures. We've noticed that HttpExceptions in child action methods are not propagated to the parent action. Even though a fragment has failed, we still see the parent request resulting in a 200, and this throws our error handling for a toss.

View 4 Replies

MVC :: Getting OutputCache When Using RenderAction And Partial View?

May 17, 2010

I am using MVC 2 and am having problems getting the OutputCache to work. My ASP.NET website has Several Views and a View Master Page. On my View Master Page I have a Menu on the left hand side displaying navigation links (implemented using JQuery).

I have implemented the Menu as a PartialView and I call this PartialView from my MasterPage using Html.RenderAction. This all works fine, my controller fetches the data from the database and the PartialView is populated.

The problem is I want to cache the Menu data since it's consistent on all pages. Yet when I add the OutputCache parameter to my Action it has no effect.

** Action **

[Code]....

** Partial View **

[Code]....

** Master Page **

[Code]....

View 11 Replies

MVC :: RenderAction With Lambda Expression In MVC 3.0 Preview 1

Sep 29, 2010

i have the following, which works:

@{Html.RenderAction("Detail", "Help", new { pageName = "press" });}
But instead i'd like to use a lambda expression to get away from the string bits. I tried using the following (which is the nearest approximation i could figure based on my limited knowledge of the engine):

@{Html.RenderAction<HelpController>(x => x.Detail("press"));}
But i get the following error:

The non-generic method 'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string, System.Web.Routing.RouteValueDictionary)' cannot be used with type arguments

However, i'm reading in the Apress MVC 2.0 book that it is in fact declared as a method that takes type arguments. Am i missing an assembly reference, or has it not been included in the MVC 3.0 Preview 1 build?

View 3 Replies

Using A RenderAction Method Throws An Exception

Dec 29, 2010

i have this (simple) code

<% Html.RenderAction("Version", "Generic"); %>

in my masterpage of my asp.net mvc 2 app. This method returns the version of the application.

i also have this code in my controller:

class GenericController : BaseController
{
[ChildActionOnly]
public string Version()
{
try
{
string assemblyFile = Assembly.GetCallingAssembly().FullName;
FileInfo fi = new FileInfo(assemblyFile);
string version = fi.LastWriteTime.Year.ToString( ) + fi.LastWriteTime.Month.ToString() + fi.LastWriteTime.Day.ToString();
return version;
}
catch (Exception e)
{
return "1.0";
}
}
}

Now i get this error:
Execution of the child request failed. Please examine the InnerException for more information.

and the innerexcpetion is:
{"The controller for path '/Account/LogOn' was not found or does not implement IController."}

What i was thinking is that maybe the code can't execute because the user is not logged on yet, and tries to redirect to the logon method etc.

So the first thing i was thinking is to grant access in the web.config (like i do with the directory that has the css and images in it, it should also be accessable when you're not logged on:

<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

but what is the path for this (version) method ?

(or maybe there is another reason for the excpetion.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved