MVC :: Encoding SquisIt Framework In Razor
Aug 22, 2010On my projects I am using SquisIt Framework and I have the following on page head:
@MvcHtmlString.Create(
On my projects I am using SquisIt Framework and I have the following on page head:
@MvcHtmlString.Create(
It's great that Razor HTML encodes by default. However, many times I have HTML in a database and want to display it literally on a page. In WebForms 4, we can use <%= %> and <%: %> to choose between encoding options. Raven's syntax is currently @(new HtmlString(Model.Greeting)).
add a shorter syntax to Razor. Something like @=Model.Greeting or @@Model.Greeting, or something else.
Has anyone else encountered a problem with Framework 4 automatically html encoding multilingual characters?I am uploading a spreadsheet with both English and Spanish characters. When I preview it on the page everything looks great however as soon as I attempt to pass it to the stored procedure the non-roman characters are being automatically converted to, what looks like, html encoding.This code worked flawlessly in 3.5 and has not been touched. The only change is that I switched to framework 4 however I haven't seen anything indicating that this would be a problem for me.
View 1 RepliesWould like to add a third party test framework (such as NUnit or MbUnit) to the drop-down list of test projects for the ASP.NET MVC3 type project in Visual Studio 2010.
This had worked before for ASP.NET MVC2 and prior, but the msdn instructions are not accurate and does not work. Creating the registry keys in the HKEY_CURRENT_USER seem to delete the keys every time the VS-2010 starts, the HKEY_LOCAL_MACHINE does not follow the same tree structure.
how to add a third party framework under ASP.NET MVC3?
I have written a web mailer that can send and receive emails and display them on a webpage.I have a problem displaying special characters though. Like Russian, and Greek and chinese.I am using openpop.net and I can get the encoding of the incoming email as one of my variables.Thing is, how do I display it? Do I set the content encoding of the whole page to what that specific email encoding is?I've got it UTF-8 at the moment and I get garbage.
View 3 RepliesIm pulling out a text field from the database which has and 's in it for line breaks. Which I have left there for pupose of being able to edit the fields later on.
So when i try to display the text I need to replace them which I have done with:
[Code]....
Simple enough. Only when I run the page the source code I get for it is:
<br />
So it seems its not encoding the < as a encode but into the form <
Does anyone know how to stop this happen. Or a method around it?
I host a website that has recently been upgraded from .NET Framework 2.0 to .NET Framework 4.0. Within the website, I have an instance of BlogEngine which still requires .NET Framework 2.0. Each website is in it's own application pool. My issue is that when I browse to the blog portion of my website, I receive a 500.19 error with the following information...
The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration The web.conf file that is listed in the error message is the config file that belongs to my root website which is running .NET Framework 4.0. How do I get the two websites to run together in the same website using different versions of the .NET Framework?
I have this cenario:One server (machine) that have framework 3.5. And one site (website) developed for framework 3.5.This site can not be modified (rebuild in other FW version, or others changes).
I'll developer a new webapplication (WAP) in framework 4.0 (using microsoft visual web developer 2010).
As I know, the new webaplication work in the server, if I install framework 4.0 in the server.
My question is: Can I install the framework 4.0 on the machine that already have framework 3.5. And continue have sites working with other frameworks version?Or, should I develop my new webapplication in framawork 3.5 ?If I can install the framework 4.0, do I need make some specify configuration during the installation?
what is Features added in Framework 2.0 over the framework 1.1? i want in Details?
View 2 RepliesDifference between .net framework 2.0 and .net framework 2.0 with service pack 2
View 4 RepliesWe are developping with .net framework 2.0 on our dev station and we deploy on web server and client desktop a 3 tiers smart client app. what is the impact of ugrading to .net framework 2.0 sp2 on our web servers WITHOUT upgrading on dev station and compilation servers?
View 2 RepliesWhat's better in ASP.NET MVC
<%= Html.LabelForModel() %>
or
<%: Html.LabelForModel() %>
I have a url that I would like to put into my web.config file. http://google.com?parcel&bob&&smithI imagine that the .net run time is upset with the ampersand's so i encoded them to be&.http://google.com?rcel&bob&&smithThis also doesn't work. Any ideas would be great, if you could supply a link to the documentation of why this is that would be even better.
View 3 Replies Can someone lead me to understanding when to set the encoding for the email step when sending new member emails. For instance what is the default or how can I tell what it is or if I want to set it in the SendMail event in code. See the thing I am wondering is when is it applied? If I set the MailDefinition-From in the html part then in code using the SendMail event set the encoding using
e.Message.From = new
MailAddress("foo@bar.com","foo",System.Text.Encoding.UTF8);
then I assume that it must actually get applied when the email is sent. Is that correct?
I'm developing a small ASP.NET Mvc project in Mono 2.4, Ubuntu 10.10. There is an array of objects, each one of them corresponds to a certain xml file. Reading of the xmls is performed with XmlTextReader. That does not work because xml files have rare "cp866nav" encoding, which is not supported by XmlTextReader ("System.ArgumentException: Encoding name 'cp866nav' not supported"). But it works fine if encoding in xml header is changed to "cp866". I found a kind of solution which consists in initializing XmlTextReader with a StreamReader with a certain encoding instead of file name, like in the code below:
XmlTextReader reader = new XmlTextReader(new StreamReader(Server.MapPath(filename), Encoding.GetEncoding("cp866")));
The issue is that the directory which contains xml files is read only (I can not change it), so I get "System.UnauthorizedAccessException: Access to the path '' is denied.". Rather strange, because XmlTextReader initialized with a filename seems to read the files. Is there any solution, considering that program cannot modify or create files?
I have a problem in my asp.net 3.5 application (C#) when I try to render in my pages characters like 'è' which are shown in a very strange manner (if i'm lucky i get a ? mark in my web page). in fact Expression Web, when i open my web site, substitutes the è char with �...How can I tell asp.net that I want to use a particular charset so that i can write in the html source letters like è without using hexadecimal codes??????I tried in the web.config this:inside the system.web namespace of the file but nothing works...
View 1 RepliesI have an ASP.Net app that allows a user to write text into a Telerik RadEditor control and then send an email.
For some reason I'm sometimes getting strange characters showing up in the email that is generated.
For example if I put the word Test's into the RadEditor box and send it... the email shows up with the text changed to: Test’s.
It seems as though the ' character was used in place of ' because if I use the later, the text would show up just fine. If I pull up the saved record within the ASP.Net apps interface it looks just fine. It also appears just fine when I view the text within the recorded of the MS SQL table it was stored in.
I'm using MailMessage to create the email. I've check the string being sent at the point just before I use SmtpClient to send the message and it looks just fine at his point. Once the email message shows up however I get the strange text (Test’s).
I'm guessing that I have an encode/decoding issue but I'm not sure how I would go about fixing this.
Continued--->
I have tried to add it to the constructor of my email class with/without mybase but that had no effect.
Public Sub New(ByVal EmailDate As DateTime, ByVal LogoPath As String)
MyBase.New()
MyBase.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
'BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Me.EmailDate = EmailDate
Me.LogoPath = LogoPath
End Sub
I also tried adding it to the code behind of the form that calls the email class just before I create a new SmtpClient but that did not seem to be correct either.
Try
returnEmail.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Dim smtpCli As New SmtpClient
smtpCli.Send(returnEmail)
Catch ex As Exception
ScriptManager.RegisterStartupScript(Me, Me.GetType, "smtpError", "alert('There was an error sending the email:
* " & ex.Message & "');", True)
End Try
I have a website on live server, and I have a the same website on local machine. both using the same database. Some links are in Arabic.
The links are ok on live server, but it is corruptted on local machine.
Both Live server and local machione are hosting the website using IIS 7.
I think that the only chance is related to IIS configuration but how??
.Net 4.0 is encoding values when using Attributes.Add. In previous versions it didn't. With the new behaviour it is no longer possible to write attributes containing single quotes.Here's an example.
<asp:TextBox ID="txtTest" runat="server" />
txtTest.Attributes.Add("onkeyup", "keyuphandler('hello')");
With the application pool framework version set to 2.0 it produces the desired result:
<input name="txtTest"
type="text" id="txtTest"
onkeyup="keyuphandler('hello')" />
With it set to 4.0 it produces an undesirable result:
<input name="txtTest"
type="text" id="txtTest"
onkeyup="keyuphandler('hello')" />
.Net 4.0 needs to be fixed to allow the developer to write attribute values containing single quotes.
I have an ASP.NET repeater pulling comment data from a database. In my ItemTemplate I placed some Label server controls bound to the fields (username of poster, date, and post text), but apparently Label does not run the data through HtmlEncode before displaying it. Is there another control I should use? How should I display HTML-encoded data from a repeater?
View 3 RepliesI am using .NET Page Routing (not MVC) to get pretty URLs (or at least removing the file extensions) on my site.On my search page, when a user searches for "stuff" it redirects then to /search/stuff for the results. However when I put in something like "stuff yes:" it gives me a HTTP 400 Bad Request Error.
I tried using javascript to encode the search value before being submitted, and confirmed that "stuff yes:" was converted to "staff%20yes%3A", yet when it performs the routing redirect, in the URL it shows "staff%20yes:" and causes the bad request. Why is it not saving the encoding for the typically illegal characters and how can I make it so?
I've recently upgraded a client's web site to .NET 4 and we've found out during the process that now GridView column values are automatically HTML encoded.
They have wide use of HTML strings in their code so we must turn that off. I know one solution would go over each column and add HtmlEncode="false". My question is - is there a way to set this to be the default for all GridView columns in this application?
What is happening is I'm trying to process international characters, but the code is falling through (giving up?) and replacing the field with a blank (well, I guess the screenshot is at the bottom)... The customer recently asked for support for Polish characters, and gave us a list of which ones he wants added.
This is the entire function:
Code:
Protected Function chkExtchars(ByVal name As String) As String
Dim j As Integer = 0
Dim dt As New DataTable
Dim c() As Char = Nothing
Dim n As Integer
Dim nc As Char
Dim newname As String = ""
dt = HttpContext.Current.Session("xChars")
[Code] ....
But maybe it needs to be sequential? (the numbers on the far left?)
Our problem is the following:
We have a website that processing products from various web shops! Users of these web shops can send products for our site what will store these products in our database. Users are sending in products through the post method of the form, and within the form the data is in hidden imput fields! Our site using UTF-8 charset, and this service is working like a charm together with other pages that has utf8 chaset too. The problem comes when someone using our service from a site that has other charset then utf8, for example: iso-8859-2.This case the special hungarian characters, like "íéáűőúöüó" are replaced with a '�' character!We have tried to convert the incoming string on server side but that case the '�' has been replaced by '?'. - still not acceptable :)