I am using AJAX.NET's update panels in the below manner. My code works perfect with .NET framework 4.0 but for some strange reasons I have to use this application in .NET framework 2.0 When I tried to run the below code in ASP.NET 2.0 on every button click page is post backing which I don't want. Can anybody tell me why page reloading even I used asp:AsyncPostBackTrigger
Code follows.
Default.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="update" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = Convert.ToString(DateTime.Now);
}
}
Web.config
<configuration>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<customErrors mode="Off"/>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
</system.web>
</configuration>
Your code is correct and runs fine even under ASP.NET 2.0. As every asynchronous postback actually does make a post back to the page, I assume you meant that clicking on Button1 in your installation makes the page completely refresh (instead of just refreshing partially). If this is the case, I think this issue may be related to a missing entry in your web.config, that prevents the client portion of ASP.NET Ajax to handle the partial postbacks correctly. Here is what you should add (excerpt):
<httpHandlers>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
I found the answer. Just change your application pool from DefaultAppPool to ClassicAppPool. Doing this everything should work fine.
Related
I am using visual studio 2013 with .net framework 4.5
crystal report version CR4VS_13_0_14.
The problem i am facing about crystal report image. I am unable to see any image and chart in my report. I visit many URL of stack overflow and scn.sap.com regarding this problem and found many solutions. I applied many solutions but i am unable to solve my problem. I am ready to answer any of your question regrading my problem kindly help me out. here is the error image CR Img Error
I am loading my images from Mssql Database. In my db the datatype I set is "Image". I can see all the images in Visual Studio Report Viewer but when I call report from browser it shows no image in report...
Here is my report viewer aspx.cs code:
ReportDocument report = new ReportDocument();
protected void Page_Init()
{
if (!Page.IsPostBack)
{
btn = Request.Form["btn"];
if (btn == "btnEmployeeCard")
{
url = Server.MapPath("~/" + "Reports/Employee/employeeCard.rpt");
}
report.Load(url);
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.SelectionFormula = selectionFormula;
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
}
}
I think this will helps you . Add this line to webconfig:
<system.webServer>
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
<!-- Added -->
<add name="CrystalImageHandler.aspx_GETR" verb="GET" path="Reports/CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
<remove name="asset" />
<add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
</handlers>
I am using SendOnlyBus with NserviceBus 5.2
and my set-up code is like
busConfiguration.UsePersistence<NHibernatePersistence,StorageType.Subscriptions>();
busConfiguration.AssembliesToScan(AssembliesToScan);
busConfiguration.UseTransport<MsmqTransport>();
busConfiguration.PurgeOnStartup(false);
busConfiguration.UseSerialization<XmlSerializer>();
return Bus.CreateSendOnly(busConfiguration);
and web.config
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MsmqTransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" />
<MsmqTransportConfig InputQueue="XXX" ErrorQueue="XXX" NumberOfWorkerThreads="X" MaxRetries="X" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="X" Endpoint="X" />
</MessageEndpointMappings>
</UnicastBusConfig>
<add name="NServiceBus/Persistence" connectionString="Data Source=XXX;database=XXX;User ID=XX;Password=XXx;" />
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
this leads to error while publishing message.
Cannot publish on this endpoint - no subscription storage has been
configured."
If i use Memory Persistence, it works fine but not with Hibernate
DB-Subscription, Not able to find out what's missing or wrong.
Appreciate any help ?.
Thanks
Explanation
NServiceBus is not configuring subscription persistence because you have asked for a send only endpoint.
Send only endpoints do not have an input queue, which means they have no way to receive and store subscriptions. Trying to Publish makes no sense if you have no subscribers.
Either
keep the send only bus, but switch from using Bus.Publish() to Bus.Send()
or
use a complete bus by calling return Bus.Create(busConfiguration) instead of return Bus.CreateSendOnly(busConfiguration)
Code sample
The only code needed to publish an event with NHibernate as subscription persistence on NServiceBus 5.2.0 and NServiceBus.NHibernate 6.1.2 is the following:
Program.cs
using System;
using NServiceBus;
using NServiceBus.Features;
using NServiceBus.Persistence;
class Program
{
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.DisableFeature<TimeoutManager>();
busConfiguration.UsePersistence<NHibernatePersistence, StorageType.Subscriptions>();
using (IStartableBus bus = Bus.Create(busConfiguration))
{
bus.Start();
bus.Publish(new SomeEvent());
Console.WriteLine("Published an event");
Console.ReadLine();
}
}
class SomeEvent : IEvent {}
}
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NServiceBus/Persistence" connectionString="Data Source=.;database=database;User ID=user;Password=password;"/>
</connectionStrings>
<appSettings>
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2012Dialect" />
</appSettings>
</configuration>
Trying to get quartz to log in ms sql server but getting error in web config file.
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="SchedulingPOC"/>
<add key="quartz.scheduler.instanceId" value="SchedulingPOC"/>
<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<!-- Configure Job Store -->
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.useProperties" value="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionString" value="Server=.\SQLExpress;Database=testDB;Trusted_Connection=True;"/>
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
</quartz>
Running the application in debug mode of Visual Studio Express for web.
Error message:
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070032
Config Error The configuration section 'quartz' cannot be read because it is missing a section declaration
Config File \?\C:\Users\Anbbb\Desktop\TheProject.Web\web.config
<quartz>
24: <add key="quartz.scheduler.instanceName" value="SchedulingPOC"/>
//The configuration section 'quartz' cannot be read because it is missing a section declaration//
Do you have the "section name" defined in "configSections" ??
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
PS
I have a "working" AdoStore example at this post:
Connecting Quartz to MS Sql Server
(One of the answers, not the question)
=======
EDIT
Here is my complete and fully working Quart.Net config, using a SqlServer database.
It ~~assumes~~ you have already created the database.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzSchedulerFromConfigFileSqlServer"/>
<add key="quartz.scheduler.instanceId" value="instance_one"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="Normal"/>
<!--
org.quartz.scheduler.idleWaitTime
Is the amount of time in milliseconds that the scheduler will wait before re-queries for available triggers when the scheduler is otherwise idle. Normally you should not have to 'tune' this parameter, unless you're using XA transactions, and are having problems with delayed firings of triggers that should fire immediately.
It defaults to every 30 seconds until it finds a trigger. Once it finds any triggers, it gets the time of the next trigger to fire and stops checking until then, unless a trigger changes. -->
<add key="quartz.scheduler.idleWaitTime" value ="5000"/>
<!-- Misfire : see http://nurkiewicz.blogspot.com/2012/04/quartz-scheduler-misfire-instructions.html -->
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"/>
<add key="quartz.jobStore.tablePrefix" value="QRTZ_"/>
<add key="quartz.jobStore.clustered" value="false"/>
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>
<add key="quartz.jobStore.dataSource" value="MySqlServerFullVersion"/>
<!-- connectionStringName -->
<!-- "true" below will result in Couldn't store job: JobDataMap values must be Strings when the 'useProperties' property is set. Key of offending value: myFloatValue
exception. -->
<!-- <add key="quartz.jobStore.useProperties" value="true"/> -->
<add key="quartz.jobStore.useProperties" value="false"/>
<add key="quartz.dataSource.MySqlServerFullVersion.connectionString" value="Server=MyServer\MyInstance;Database=QuartzDB;Trusted_Connection=True;Application Name='quartz_config';"/>
<add key="quartz.dataSource.MySqlServerFullVersion.provider" value="SqlServer-20"/>
</quartz>
</configuration>
This code should work....
NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
You must change your connection string to an EXISTING database.....that is the Quartz database.....creating using the scripts provided in one of the downloadable projects.
Like this maybe:
https://subversion.assembla.com/svn/pms_michael/database/tables/tables_sqlServer.sql
Current i am using windows shared hosting. I need to redirect my sub domain to a new domain(including the entire path).
For example, when user visit to http://oldsubdomain.olddomain.com/page1/topic1 , it will redirect user to http://newdomain.com/page1/topic1
This is the method suggest by my service provider
<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
But this way seems like not able to redirect the entire url. Any suggestions?
Thanks
*UPDATE
Trying to redirect using web.config as below, but still get 500 Internal error, any idea?
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rule name="CName to URL" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.olddomain\.com$" />
</conditions>
<action type="Redirect" url="http://newdomain.com/{R:0}" />
</rule>
</rewrite>
</system.webServer>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
</configuration>
Why not use the redirect method?
private void Page_Load(object sender, System.EventArgs e)
{
response.redirect("http://newdomain.com/page1/topic1");
}
I've been trying to resolve a 404 error received when trying to access ELMAH.axd. The ELMAH email functionality worked, but I could not navigate to the axd. Now, I'm getting 500.22 - Internal server error. Can someone spot the error in my code or suggest some recourse short of disabling ELMAH?
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>
<system.web>
<authentication mode="Windows" />
<authorization>
<allow roles="ViewOnly,Admins" />
<deny users="*" />
</authorization>
<elmah>
<security allowRemoteAccess="1" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahConnectionString" />
<!-- email configured here -->
</elmah>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
</httpModules>
<httpHandlers>
<add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</modules>
<location path="elmah.axd">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
And in Global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
I'm using a database to record ELMAH data.
What am I missing? I've read so many posts and it seems that there is no one right answer, I suppose given the several ways applications and servers can be configured.
The error you are seeing definitely looks like a configuration issue.
HTTP 500.22 - "An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode."
I found this link that provides some details on breaking changes in II7. More details specific to the web.config can be found here.
Do you have the ELMAH handler configured in the system.webSever section of your web.config? If not, I believe adding it should resolve your issue:
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
All I can see is that:
You are trying to make ELMAH logging errors into a database, but the connection string ElmahConnectionString is not defined anywhere. BTW, you should start trying to use logPath="~/App_Data" instead; if all runs well, then implement the database connection.
deny users = "*" means deny everyone; deny users = "?" means deny unauthenticated users. I guess what you want is the latter.
What mode is your application pool running in (classic or integrated)? I had this problem and found that Elmah started working after I change my app pool to integrated mode.