Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:04:15+00:00 2026-06-08T19:04:15+00:00

I’m attempting to inject some text (specifically a few lines of javascript code), into

  • 0

I’m attempting to inject some text (specifically a few lines of javascript code), into the HTML response from Nancy after it’s found the view and processed everything. The After hook seems to be where I want to be doing this. I can access the Response object through the context I’m given, but my attempts to retrieve any data from it fails. It is of type Action<Stream> so I’ve been trying to get it written into memory, then a string as follows:

public HelloModule()
{
    After += ctx => {
                var stream = new MemoryStream();
                ctx.Response.Contents.Invoke(stream);

                stream.Position = 0;
                using (var reader = new StreamReader(stream))
                {
                    var content = reader.ReadToEnd();
                }
    };

    Get["/"] = p => View["Issues/Views/SingleIssue"];            
}

But, when this runs I get an exception on the line ctx.Response.Contents(stream);. The exception is an InvalidOperationException which only states that "CSRF is not enabled on this request".

So, my question is: How do I get Nancy to allow me access to the HTML of the current Response its produced? Or am I completely off with how I’m trying to do this? Is there a better way?

Edit 2: This appears to be an issue with the SuperSimpleViewEngine. I just created a new, clean project with a single view. SSVE can reproduce it, but the spark view engine will work just fine.

Edit 1:

As requested some more information. The code above now contains the entire constructor for the module. I have no custom bootstrapper or other logic in the way. The view is a rather simple view using the default SuperSimpleViewEngine, it’s composed exactly as follows:

Master.sshtml

<html>
<head>
    <script type="text/javascript" src="/Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.22.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.21.custom.min.js"></script>
    <script type="text/javascript" src="/Scripts/dais-exts.js"></script>
    <link rel="stylesheet" type="text/css" href="/Content/Style.css" />
    <link rel="stylesheet" type="text/css" href="/Content/jquery-ui-1.8.21.custom.css" />
    @Section['Head']
</head>
<body>
    @Section['Content']
</body>
</html>

SingleIssue.sshtml

@Section['Head']
    <title>Hello!</title>
@EndSection

@Section['Content']
    <h2>View/Edit Issue</h2>

    <form id="issue-form" method="post">
        <input type="hidden" name="HttpMethod" value="Put" />
        <input type="submit" />
    </form>
@EndSection
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:04:17+00:00Added an answer on June 8, 2026 at 7:04 pm

    Answering the question, just so anyone finding this knows what’s going on.

    This is actually a bug in Nancy (version 0.11) and only occurs when using the SuperSimpleViewEngine. Unfortunately there’s no easy workarounds or solutions, but a fix has been applied to the source. So, the options to resolve the issue are:

    • Wait for Nancy 0.12.
    • Build a new version yourself from source.
    • Use a different view engine.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.