nikmd23 / CourtesyFlush

The source for my CourtesyFlush NuGet package.
Apache License 2.0
72 stars 6 forks source link

Implementation of Flush Globally #14

Open Ankita-XIT opened 9 years ago

Ankita-XIT commented 9 years ago

I want to implement Flush in my whole project. But as I am working on nopCommerce based web application I am little bit confused How can I implement it because it does not contain any _Lauout.cshtml page as you have mentioned in your document that I need to write @Html.FlushHead() in _Lauout.cshtml page.

Can you please help me with this?

Thanks, Ankita

simonpucher commented 9 years ago

Hi Ankita-XIT, i just downloaded the nopCommerce source code from codeplex. Just go to nop.Web => Views => Shared. Then you are able to see the master pages. In that case the master page is not called "layout" they call it _Root.cshtml and _Root.Head.cshtml. Hope this helps!

Ankita-XIT commented 9 years ago

Hello, I have follow the steps you suggested. I have created one new view page named _Head.cshtml. Placed code after closing tag in _Root.Head.cshtml page. And it also works but for login and logout process I am getting this error: Server cannot modify cookies after HTTP headers have been sent.

Can you please suggest which is the best place to put this code in view page: @Html.FlushHead()

nikmd23 commented 9 years ago

@Ankita-XIT,

I think you have two options here:

  1. If the cookie that is being written is an AntiForgery token, then you'll be able to add FlushAntiForgeryToken = true to the FlushHead attribute and fix your problem.
  2. My feeling is that this is not the case. It's probably a nopCommerce specific cookie. In that case, I'd recommend disabling CourtesyFlush on those two actions.

Unfortunately, there isn't a great way to disable specific actions if you are globally enabling flushing. There's an item on the backlog #6 to do this though, if you or someone else would like to contribute it.

Ankita-XIT commented 9 years ago

Hello,

If I want to customized your code then which files I need to add in my project? I have added ContollerBaseExtension.cs, FlushHeadAttribute.cs & HtmlHelperExtension.cs files. Moreover, I have restricted Login and Logout Action methods by implementing another filter attribute.

simonpucher commented 9 years ago

The best you can do is to fork the whole project using GitHub client, change or modify code, compile it and then you add a reference to your project.