asp.net mvc translate <asp> to razor markdowndeep

172 Views Asked by At

Working on a 'school' project what is kind of a stackoverflow 'remake'. The 'remake' is finished except one part.

Trying to figure out how to implement markdown(deep) so there can be questions and answers posted witch rich content instead of only text.

Now after spending literally a half day I found and managed to get an example running.

The only problem I have, it's not working on my project.

This is the source I use MarkdownDeep

So I am using the exact same way how it's done in given source in my own controller for the view: 'NewQuestion'

Static (example) content to show:

static string m_Content =
  @"# Edit this Page with MarkdownDeep
    This demo project shows how to use MarkdownDeep in a typical ASP.NET MVC application.
  * Click the *Edit this Page* link below to make changes to this page with MarkdownDeep's editor
  * Use the links in the top right for more info.
  * Look at the file `MarkdownDeepController.cs` for implementation details.
    MarkdownDeep is written by [Topten Software](http://www.toptensoftware.com).
    The project home for MarkdownDeep is [here]
    http://www.toptensoftware.com/markdowndeep). ";

Controller:

public ActionResult Index()
{
    // View the user editable content
    // Create and setup Markdown translator
    var md = new MarkdownDeep.Markdown();
    md.SafeMode = true;
    md.ExtraMode = true;
    // Transform the content and pass to the view
    ViewData["Content"] = md.Transform(m_Content);
    return View();
}

View (NewQuestion):

..
<div class="row">
    <div class="col-md-8">
       @ViewData["Content"]
    </div>
</div>
...

Result

enter image description here

So as you can see, there is no error like the js or jQuery file isn't found or anything. And it seems to me that the content correctly transformed.

Could it be because the example runs from <asp> and I am using razor?

I am really confused and can't figure out how to solve shit. Already spent hours to understand what is going on. Also, just started on asp.net so you can really help me out here.

p.s, if there is more information/details need I am happely to update this post.

1

There are 1 best solutions below

1
On BEST ANSWER

Try using Html.Raw()

@Html.Raw(@ViewData["Content"])