Problem mit Html-Code in asp.net

wakebunny

Grünschnabel
hallo!

benutze asp.net mit vb mit einer access-db, dreamweaver mx!
habe folgendes problem:
meine aspx-seite zeigt inhalte aus einer datenbank an, u.a. auch einen html-codierten inhalt zwecks darstellung.
jetzt habe ich einen admin-bereich erstellt mit "neuer datensatz einfügen" "datensatz ändern" etc.
sobald ich einen datensatz ohne html-code erstelle -> funktioniert
aber wenn ich einen datensatz mit html-code erstelle -> fehlermeldung (serverfehler)
(freigegeben für schreiben und lesen, gleiches system funktionierte unter asp, nur eben jetzt mit asp.net nicht mehr!)

welche einstellungen müssen hier vorgenommen werden?

gruß wakebunny
 
hallo!

folgende seite wird angezeigt:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
 
hi!

hab jetzt ne genauere fehlermeldung:

A potentially dangerous Request.Form value was detected from the client (infos="... und noch <b>einmal</b>").
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (infos="... und noch <b>einmal</b>").

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (infos="... und noch <b>einmal</b>").]
System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +240
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +99
System.Web.HttpRequest.get_Form() +121
System.Web.UI.Page.GetCollectionBasedOnMethod() +70
System.Web.UI.Page.DeterminePostBackMode() +128
System.Web.UI.Page.ProcessRequestMain() +2112
System.Web.UI.Page.ProcessRequest() +217
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
 
Schau dir mal die web.config Dateien in deiner Applikation an und setze dort das 'cutomErrors' Attribut auf 'Off'

<customErrors mode="Off"/>

Dann solltest du eine detaillierte Fehlerbeschreibung bekommen mit der du mehr anfangen kannst :)
Empfhielt sich zum testen der Seiten das immer so zu machen. Nur beim publizieren sollte man nicht vergessen es dann wieder umzustellen.

EDIT: // Ok, gleichzeitiger Post :)

You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section.
Das kannst du ja mal versuchen.

Ansonsten: Hast du die SQL-Anweisung parametisiert gemacht?
 
Zuletzt bearbeitet:
Also :
Wenn du einen neuen Datensatz einfügst, dann machst du das wahrscheinlich mit einem CommandObjekt (ich nehme nun hier mal als beispiel ein SQLCommand, obwohls deines eine Access-DB ist weils mir einfach besser liegt und außerdem ists das gleiche:))

Mal ein Beispiel:

Code:
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
command.Parameters.Add("@Value1",SqlDbType.Text);
command.Parameters.Add("@Value2",SqlDbType.Text);
command.Parameters.Add("@Value3",SqlDbType.Text);
command.Parameters["@Value1"].Value = "Mein Wert 1";
command.Parameters["@Value2"].Value = "Mein Wert 2";
command.Parameters["@Value3"].Value = "Mein Wert 3";
// nicht: command.CommandText = "INSERT INTO Tabelle (Spalte1, Spalte2, Spalte3) VALUES ('Mein Wert 1', 'Mein Wert 2', 'Mein Wert 3')";

command.CommandText = "INSERT INTO Tabelle (Spalte1, Spalte2, Spalte3) VALUES (@Value1, @Value2, @Value3)";

connection.Open();
command.ExecuteNonQuery();
connection.close();

'You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. '

Das heißt folgendes:
Entweder auf der .aspx Seite in der Direktive (Am Anfang der Seite) das eintragen, dass es folgendermaßen aussieht:
<%@ Page Language="c#" ValidateRequest="False" ...%>

oder eben in der web.config das Page-Tag umändern (oder hinzufügen, je nachdem), sodass es so aussieht:
<page validateRequest="false" />
 
Hallo.

Diese Meldung wird ausgeführt weil HTML Code in einem Formular übermittelt wurde. Die Lösung hat dir zovax bereits verraten.

wakebunny, bitte achte in Zukunft ein bisschen mehr auf deine Groß-/Kleinschreibung. Danke!

MfG,
Alex
 
Zurück