Could not find schema information for the element 'httpruntime' - asp.net

I'm trying to increase the execution timeout and file upload limit on my asp.net website but when i try to add
<httpRuntime
executionTimeout="110"
maxRequestLength="4096">
</httpRuntime>
i get the following errors:
Could not find schema information for the element 'httpruntime'.
Could not find schema information for the element 'executionTimeout'.
Could not find schema information for the element 'maxRequestLength'.
According to this msdn library link this is how I'm supposed to do it,so what am I missing here ?

Have you tried:
<location path="YourUploadPage.aspx">
<system.web>
<httpRuntime maxRequestLength="{your value here}"
executionTimeout="{your value here}" />
</system.web>
</location>
means, <httpRuntime> section should be inside <system.web> or <location><system.web> sections.

Related

Transforms for CSS and Views in MVC

I have an MVC application which I am deploying out to a staging server using Team City. I have created a Web.Staging.config transform to handle the different database connection, certificates and service calls.
On this staging server I have had a request to have the title of the Index view to read "TEST SYSTEM" and to have a different colour scheme to signify, at a glance that the user is on the test system.
So far I have handled this by changing the view on the file system in notepad, and swapping the bootstrap.css file to one with a different theme however every time I do a new commit/deploy these changes are wiped and its becoming tiresome.
Is there anyway to handle CSS/view changes per server by using a similar transform system as employed to handle the web.config
There's not really an easy way to transform CSS files like that, but what you could do is have your master CSS file link in your config file, so your view would be something like:
<link href='#ConfigurationManager.AppSettings["MainCSS"]'>
Then your web.Debug (and other transformations) could point to the correct path:
<add key="MainCSS" value="/Content/Site.css" />
And your web.Staging config could point to another:
<add key="MainCSS" value="/Content/Staging/Site.css" />
You can also apply the above logic for your Index view:
public ActionResult Index()
{
string viewName = ConfigurationManager.AppSettings["MainView"];
return View(viewName);
}
Then have in your web.Debug (and others):
<add key="MainView" value="Index" />
And in your web.Staging:
<add key="MainView" value="IndexStaging" />
One solution could be to add a key to the web.config and read it using the WebConfigurationManager.AppSettings. Those settings can be transformed. In your view you can check this setting if you need to change the title and if you need to load an additional css file.
In your web.config:
<appSettings>
<add key="IsTestSystem" value="False" />
</appSettings>
and in as transform:
<appSettings>
<add key="IsTestSystem" value="True" xdt:Locator="Match(key)" xdt:Transform="SetAttributes"/>
</appSettings>
In your view / layout:
if (Boolean.TryParse(WebConfigurationManager.AppSettings["IsTestSystem"] ?? "False", out run)) {
// include css file for test system or modify the title
}
And, if you want, you can just switch between the two bootstrap.css files.

Page enableEventValidation="true" error

I'm creating a client insert form, in this form has a <asp:HiddenField/> named Id for save selected client id, but when I try submit form, it is on Page enableEventValidation="true" error, when I rename this HiddenField for any other Id, it's work
<asp:HiddenField runat="server" ID="Id" />
My form can submit success when I set enableEventValidation="false", but maybe I will need it in future
How to can I resolve this problem? keep HiddenField named Id
PrintScreen:
You've pretty much answered your own question. The only way to make this work is set enableEventValidation="false" or rename your HiddenField
Renaming it would be the best solution here, for security reasons
If you're are using framework 4.0 then entry in web.config ()
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
If you're using framework 4.5 then entry in web.config (requestValidationMode="2.0")
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" requestValidationMode="2.0"/>
</system.web>
Link
This might not be the solution for your problem, but i was having same problem and solved it by checking for postback before binding data.
(!IsPostBack)
{
binddata(); //this was my gridview binding function
}
This error also occurs when there is another form on the page that does not contain runat = server. Please check if there is another form on the master page or the current page.

A dangerous Request.Form when value entered into a textbox

I have a simple aspx page through which i am entering Text into a textbox the text are coming though texteditor so the text are with html tags.
Such as <p>My name</p>
the error which i am getting is like:
Server Error '/' Application
A potentially dangerous Request.Form value was detected from the client (ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$TxtTopicName="<p>kdarftghjh</p>").
What type of error is this and how could i resolve such error.Thanks for any assistance.
If you're using webforms you can add the following to your page-declaration:
validateRequest="false"
You are having html tags in this input(<,>). just remove it or encode it. of if you really need to do like this try adding following part to web.config
<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
<pages validateRequest="false">
</pages>
</configuration>

How to get Correct QueryString Value from URL having UNICODE value in asp.net?

I have a field with nvarchar datatype to store UNICODE value. This field is bound to Repeater Control from which i am redirecting to other page on clicking the link. When this field contains the numeric value in field then, i get the correct QueryString and it displays the Redirected page. But, When it contains some unicode charater(Other than Number or English Character) then it show the value '?????' in QueryString of 'fhn'. How to get this UNICODE QueryString value as it is and display result?
In Repeater ItemTemplate:
<b>घर क्र./House No.</b><%# Eval("HouseNumber")%>
या पत्यावरील
In .cs file:
string HouseNumber = Request.QueryString["fhn"].ToString().Trim();
//here i get the '????' value if it contains unicode value.
Help appreciated!
Try changing it to something more like this:
<!-- Web.Config Configuration File -->``<configuration>
<system.web>
<customErrors mode="Off"/>
<globalization fileEncoding="iso-8859-1" requestEncoding="iso-8859-1"responseEncoding="iso-8859-1"/>
</system.web>
</configuration>
You'll have to be a more precise. You could set request and response encoding in your web.config file:
<system.web>
<globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" />
</system.web>

Getting Swedish characters from a textbox control

I'm getting my text from a textbox from code-behind using control.Text()
but I'm not getting the proper characters, I want "ÅÄÖ". Must be some problem with the text encoding but I've already checked my encoding settings in VS. Someone??
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
source: http://support.microsoft.com/kb/893663
The letters looks swedish - hence I have made the following to match swedish letters. If it's another language change the culture.
in your web.config set the following
<configuration>
<system.web>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="sv-SE" uiCulture="en-US" />
</system.web>
</configuration>

Resources