![]() |
3 часа назад
![]() |
Wiki |
[Serializable]
public class CustomerInfo
{
private string firstName;
public string FirstName
{
get
{
return firstName;
}
set
{
if (firstName == value)
return;
firstName = value;
}
}
private string lastName;
public string LastName
{
get
{
return lastName;
}
set
{
if (lastName == value)
return;
lastName = value;
}
}
private string company;
public string Company
{
get
{
return company;
}
set
{
if (company == value)
return;
company = value;
}
}
[NonSerialized]
private string testNonSerialized = "NonSerialized string";
}
///
/// databinding & controls initialization
///
private void LoadData()
{
// db request and customers collection initialization
customers.Add(new CustomerInfo
{
FirstName = "John",
LastName = "Smith",
Company = "ITS"
});
customers.Add(new CustomerInfo
{
FirstName = "Alise",
LastName = "Young",
Company = "IT Research"
});
customers.Add(new CustomerInfo
{
FirstName = "Alex",
LastName = "Gullini",
Company = "AD Analitics"
});
}
![]() |
Внешний вид страницы |
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JSON._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>
<style type="text/css">
td { border:solid 1px #eaeaea; }
</style>
<script language="javascript" type="text/javascript">
var customerID = 0;
function onClickHandler() {
serverCall('get,' + customerID);
customerID++;
if (customerID > 2) {
customerID = 0;
}
}
function onSuccessfullHandler(responseFromServer) {
var customer = Sys.Serialization.JavaScriptSerializer.deserialize(responseFromServer);
if (customer != null) {
// binding
var txtFirstName = $get('txtFirstName');
var txtLastName = $get('txtLastName');
var txtCompany = $get('txtCompany');
txtFirstName.value = customer.firstName;
txtLastName.value = customer.lastName;
txtCompany.value = customer.company;
}
else
customerID = 0;
}
</script>
</head>
<body>
<form id="frmMain" runat="server">
<asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager>
<div>
<table style="border:solid 1px grey;">
<tr>
<td>
First name:
</td>
<td>
<input type="text" id="txtFirstName" />
</td>
</tr>
<tr>
<td>
Last name:
</td>
<td>
<input type="text" id="txtLastName" />
</td>
</tr>
<tr>
<td>
Company:
</td>
<td>
<input type="text" id="txtCompany" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" id="btnGetNextCustomer" onclick="onClickHandler();" value="Next customer"/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
public void RaiseCallbackEvent(string eventArgument)
{
string[] argsFromClient = eventArgument.Split(',');
if (argsFromClient.Length >= 2)
{
switch (argsFromClient[0])
{
case "get":
int customerID;
if (int.TryParse(argsFromClient[1], out customerID))
{
this.currentCustomerID = customerID;
}
break;
default:
break;
}
}
}
public string GetCallbackResult()
{
string result = "{}";
if (this.currentCustomerID < this.Customers.Count)
{
CustomerInfo customer = this.Customers[this.currentCustomerID];
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(CustomerInfo));
using (MemoryStream ms = new MemoryStream())
{
ser.WriteObject(ms, customer);
result = Encoding.Default.GetString(ms.ToArray());
}
}
return result;
}
![]() |
Ответ со стороны сервера |
function onSuccessfullHandler(responseFromServer) {
var customer = Sys.Serialization.JavaScriptSerializer.deserialize(responseFromServer);
if (customer != null) {
// binding
var txtFirstName = $get('txtFirstName');
var txtLastName = $get('txtLastName');
var txtCompany = $get('txtCompany');
txtFirstName.value = customer.firstName;
txtLastName.value = customer.lastName;
txtCompany.value = customer.company;
}
else
customerID = 0;
}
![]() |
Ответ со стороны сервера |
![]() |
Десериализованный объект customer на клиенте |
[WebMethod(true)]
public static string PageMethodTest(string arg)
{
return "this is a string from server";
}
<asp:scriptmanager runat="server" id="scriptManager" enablepagemethods="true">
</asp:scriptmanager>
<asp:button id="btnPageMethodInvocation"
runat="server"
text="Page method invocation"
onclientclick="btnPageMethodInvocation_clientHandler();return false;">
</asp:button>
function btnPageMethodInvocation_clientHandler() {
PageMethods.PageMethodTest("test", onSuccessfullHandler);
}
![]() |
function onSuccessfullHandler(result) {
alert(result);
}
![]() |
Сигнатура метода |
function btnPageMethodInvocation_clientHandler()
PageMethods.PageMethodTest("test", onSuccessfullHandler)
public static string PageMethodTest(string arg)
function onSuccessfullHandler(result)
![]() |
Результат вызова |
namespace Callbacks.ScriptServices
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService()]
public class ScriptService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public string ScriptServiceTest(string arg)
{
return "this is a string from script service method";
}
}
<title></title>
<script language="javascript" type="text/javascript"
function btnPageMethodInvocation_clientHandler() {
Callbacks.ScriptServices.ScriptService.ScriptServiceTest("test",
onSuccessfullHandler);
}
function onSuccessfullHandler(result) {
alert(result);
}
</script>
<form id="form1" runat="server">
<asp:scriptmanager runat="server" id="scriptManager" enablepagemethods="true">
<services>
<asp:servicereference path="~/ScriptServices/ScriptService.asmx">
</asp:servicereference>
</services>
<div>
<asp:button id="btnPageMethodInvocation"
runat="server" text="Script service method invocation"
onclientclick="btnPageMethodInvocation_clientHandler();
return false;">
</asp:button></div>
</asp:scriptmanager>
</form>
public partial class ICallbackEventHandlerImplementor : System.Web.UI.Page, ICallbackEventHandler
{
#region ICallbackEventHandler Members
public string GetCallbackResult()
{
string resultFromServer = "this is a string from ICallbackEventHandler implementor";
return resultFromServer;
}
public void RaiseCallbackEvent(string eventArgument)
{
string[] argsFromClient = eventArgument.Split(',');
if (argsFromClient.Length >= 2)
{
switch (argsFromClient[0])
{
case "add":
break;
default:
break;
}
}
}
#endregion
}
function serverCall(arg)
{
WebForm_DoCallback(…arg)
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string webFormDoCallbackScript = this.ClientScript.GetCallbackEventReference(this, "arg", "onSuccessfullHandler", null, true);
string serverCallScript = "function serverCall(arg){" + webFormDoCallbackScript + ";\n}\n";
if (!this.ClientScript.IsClientScriptBlockRegistered("serverCallScript"))
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "serverCallScript", serverCallScript, true);
}
}
}
![]() |
<script type="text/javascript">
//<![CDATA[
function serverCall(arg){WebForm_DoCallback('__Page',arg,onSuccessfullHandler,null,null,true);
}
//]]>
</script>
<head id="Head1" runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function btnPageMethodInvocation_clientHandler() {
serverCall('add,' + 10);
}
function onSuccessfullHandler(result) {
alert(result);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnPageMethodInvocation"
runat="server"
Text="ICallbackEventHandlerImplementor sample"
OnClientClick="btnPageMethodInvocation_clientHandler();return false;" />
</div>
</form>
</body>
</html>
![]() |
Дуэша |
kept getting 404.3 errors, so I started examining IIS to make sure that the right
stuff is registered. After not finding anything wrong, I started looking at the WCF
installation. I found that my WCF services where not installed. You can do the
installation manually by running "ServiceModelReg.exe", which was found at
%Windows%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\.
SQL Server blocked access to procedure 'sys.xp_makewebtask' of component 'Web Assistant Procedures'
because this component is turned off as part of the security configuration for this server.
A system administrator can enable the use of 'Web Assistant Procedures' by using sp_configure.
For more information about enabling 'Web Assistant Procedures',
see "Surface Area Configuration" in SQL Server Books Online.
The statement has been terminated.
sp_configure 'Web Assistant Procedures'
sp_configure 'Web Assistant Procedures', 1
reconfigure with override
execute master.dbo.sp_makewebtask @outputfile = 'D:\Cache\cache.txt', @query = N'SELECT top 1 * FROM dbname.dbo.test_table'
10 Apr 2008, 1:58 PM UTC
Jonathan Kehayias
These stars recognize your participation in the forums. For more information about the different levels of stars, and how points are earned, please see the FAQ.
Answerer
Posts 2,350
Answer Re: How to use UNC name with sp_makewebtask in sql server
Answer Was this post helpful ? Reply Quote
The Service Logon Account for SQL Server will need to have access to
the that shared path to read or write from there.
If SQL Server is running as Local System, you should change this to a
dedicated login account to a set user, and then grant that user
access to the shared path you want:
Also, you can't use mapped drives like you would probably expect.
The drive is mapped at login, and is not actually a persistent drive available to the services.
How to change the SQL Server or SQL Server Agent service account without using SQL Enterprise Manager in SQL Server 2000 or SQL Server Configuration Manager in SQL Server 2005
declare @file_location varchar(100)
set @file_location = '\\unc name of web application server\TemporaryFiles\cache.txt'
execute master.dbo.sp_makewebtask @outputfile = @file_location, @query = 'SELECT top 1 * FROM dbo.test_table'
Msg 16821, Level 11, State 1, Procedure sp_makewebtask, Line 131
SQL Web Assistant: Could not open the output file.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'authorizationBehavior' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.
Parameter name: element
Source Error:
Line 449:
protected override Message OnAfterReceivedRequest(string authToken, Message request)
{
// проблема описана в WCF
// http://wcf.netfx3.com/blogs/wcf_team_bloggers/archive/2006/07/26/This-message-cannot-support-the-operation-because-it-has-been-copied.aspx
// http://blogs.msdn.com/drnick/archive/2006/07/26/This-message-cannot-support-the-operation-because-it-has-been-copied.aspx
// This message cannot support the operation because it has been copied
// This message cannot support the operation because it has been readed
MessageBuffer buffer = request.CreateBufferedCopy(int.MaxValue);
Message returnMessage = buffer.CreateMessage();
string parameters = buffer.CreateMessage().GetReaderAtBodyContents().ReadInnerXml();
buffer.Close();
string action = request.Headers.Action;
AuthorizationManager.RegistryOperationInvocation(authToken, action, parameters);
return returnMessage;
}
Sys.Debug.fail('');
if (typeof(siStatuses) != "undefined" && siStatuses != null)
{
WS.Scripts.ScriptService.CheckStockImagesDownloading(siStatuses, OnCheckComplete, OnCheckFailed);
}
Sys.Net.WebServiceProxy.invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, this.get_timeout());
........
this._xmlHttpRequest.send(body);
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
.ajax__tab_default .ajax__tab_inner {height : 100%;}
.ajax__tab_default .ajax__tab_tab {height : 100%;}
.ajax__tab_xp .ajax__tab_hover .ajax__tab_tab {height : 100%;}
.ajax__tab_xp .ajax__tab_active .ajax__tab_tab {height : 100%;}
.ajax__tab_xp .ajax__tab_inner {height : 100%;}
.ajax__tab_xp .ajax__tab_tab {height:100%}
.ajax__tab_xp .ajax__tab_hover .ajax__tab_inner {height : 100%;}
.ajax__tab_xp .ajax__tab_active .ajax__tab_inner {height : 100%;}
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Background
IIS has web sites, which are containers for virtual applications which contain virtual directories. The application in a site can be accessed through one or more IIS binding.
IIS bindings provide two pieces of information – binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site.
Example
Binding protocol – HTTP
Binding Information – IPAddress , Port, Hostheader
IIS supports specifying multiple IIS bindings per site, which results in multiple base addresses per scheme. A WCF service hosted under a site allows binding to only one baseAddress per scheme.
Solution in .Net Fx 3.0:Supporting Multiple IIS Bindings Per Site
Solution in .Net Fx3.5: BaseAddressPrefixFilters
Specifying a prefix filter at the appdomain level via config allows for filtering out unnecessary schemes. The incoming base addresses, supplied by IIS, are filtered based on the optional prefix list filter. By default, when prefix is not specified all addresses are passed through. Specifying the prefix will result in only the matching base address for that scheme to be passed through.
Example
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix=”net.tcp://payroll.myorg.com:8000”/>
<add prefix=”http://shipping.myorg.com:9000”/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
In the above example, net.tcp://payroll.myorg.com:8000 and http://shipping.myorg.com:9000 are the only base addresses, for their respective schemes, which will be allowed to be passed through. The baseAddressPrefixFilter does not support any wildcards .
The baseAddresses supplied by IIS may have addresses bound to other schemes not present in baseAddressPrefixFilter list. These addresses will not be filtered out.