在我的RESTful WCF Serice中,我需要传递一个类作为URITemplate的参数.我能够传递一个字符串或多个字符串作为参数.但是我有很多字段可以传递给WCF服务.所以我创建了一个类并将所有字段添加为属性,然后我想将此类作为一个参数传递给URITemplate.当我试图将类传递给URITemplate时,我收到错误"路径段必须有类型字符串".它不接受类作为参数.知道如何将类作为参数传递.这是我的代码(inputData是类)
[OperationContract]
[WebGet(UriTemplate = "/InsertData/{param1}")]
string saveData(inputData param1);
Run Code Online (Sandbox Code Playgroud) 最近我开发了一个wcf服务.它一直工作到昨天.我能够在内置的WCF测试客户端中使用VS2010进行测试.从昨天起,我无法在WCF测试客户端中看到我的服务.当我按F5时,它打开Wcf测试客户端窗口,在底部显示Servie已成功添加.但它不加载任何服务.我试图从文件/添加服务手动添加它,但它仍然没有加载.可能是什么问题呢.我非常感谢你的帮助.这是我的Web.config.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings/>
<client/>
<services>
<service behaviorConfiguration="myproj.ServiceBehavior" name="myproj.Service">
<endpoint address="" binding="webHttpBinding" contract="myproj.IService" behaviorConfiguration="REST">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="myproj.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 以下标签的Html(RTF/doc)等价物是什么?
<IMG SRC = "planet.jpg" align="left" Width = "600">
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我有一个方法需要返回一个ConnectionStringSettings对象。由于数据库和服务器名称会动态变化,我需要动态构造连接字符串。
如何将 a 转换string为ConnectionStringSettings?
public ConnectionStringSettings getConnection(string server, string database)
{
//ConnectionStringSettings connsettings = new ConnectionStringSettings();
string connection = ConfigurationManager.ConnectionStrings["myConnString"].ToString();
connection = string.Format(connection, server, database);
// Need to convert connection to ConnectionStringSettings
// Return ConnectionStringSettings
}
Run Code Online (Sandbox Code Playgroud)
--web.config
<add name="myConnString" connectionString="server={0};Initial Catalog={1};uid=user1;pwd=blah; Connection Timeout = 1000"/>
Run Code Online (Sandbox Code Playgroud) 我试图从浏览器测试我的Rest Wcf服务.当我试图从浏览器发送一些值时,我收到以下错误."由于EndpointDispatcher上的AddressFilter不匹配,无法在接收方处理消息.
检查发送方和接收方的EndpointAddresses是否一致."
然后我添加了[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)].然后我得到一个不同的错误.
"由于EndpointDispatcher上的ContractFilter不匹配.这可能是由于合同不匹配(发送方和接收方之间的操作不匹配)或发送方与接收方之间的绑定/安全性不匹配.
检查发送方和接收方是否具有相同的合同,相同的绑定(包括安全要求,例如消息,传输,无)."
我们可以从浏览器传递值到Rest Wcf服务吗?
我试图从浏览器传递以下值.
http://mywebsite/Service1.svc/mymethod/Firstname,Lastname,LosAngles,CA
Run Code Online (Sandbox Code Playgroud)
这是我的web.confg文件
<system.serviceModel>
<services>
<service behaviorConfiguration="Wcfservice1.ServiceBehavior" name="="Wcfservice1.Service1">
<endpoint address="" binding="webHttpBinding" contract="Wcfservice1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Wcfservice1.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 我有以下SQL Server表
我想要从下表中最新的所有前4个不同的代码
记住我希望返回所有列而不仅仅是代码列.
sno city state country code date
1 new york NY US 1234 1/1/2013
2 Houston TX US 2234 1/6/2013
3 LA CA US 1123 1/2/2013
4 Chicago IL US 1244 1/3/2013
5 Brooklyn NY US 1234 1/4/2013
6 Dallas TX US 2234 1/5/2013
Run Code Online (Sandbox Code Playgroud)
我的以下选择查询返回重复的代码,但我想要不同的最新代码.
select top 4 * from table1 where code in (select distinct code from table1)
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
在我的C#项目中,我需要向UniqueIdentifier列插入一些空值.
对于字段城市Guid,状态Guid字段,如果没有可用的值(uniqueidentifier),我应该能够插入空值.我收到以下错误
"从字符串转换为uniqueidentifier时转换失败."
这是我的代码.
string Query = @"INSERT INTO mytable
(table_GUID,
Date,
city_GUID,
state_GUID,
)
VALUES
('" + tableGUID + @"',
'" + Date + @"',
'" + cityGUID + @"',
'" + stateGUID + @"'
)
string insert = sql.executeNonQuery(Query);
Run Code Online (Sandbox Code Playgroud) 在我的程序(asp.net,C#)中,我使用gridview来显示数据.它从以下查询中获取数据.
select * from Nametable where NameID in (4,3,1,22,15,8,9,5,7)
Run Code Online (Sandbox Code Playgroud)
但问题是Gridview以NameID的升序排序顺序显示数据(1,3,4,5,7,8,9,15,22).我不想要对数据进行排序,它应该完全按照我在查询中提到的方式显示(4,3,1,22,15,8,9,5,7)
这是我的代码
private void loadGridView()
{
Query = "select * from Nametable where NameID in (4,3,1,22,15,8,9,5,7)"
DataSet ds = SqlHelper.ExecuteDataset(CommonSettings.Constring, CommandType.Text, Query);
GridView1.DataSource = ds;
GridView1.DataBind();
}
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我需要将一些值从一个页面(页面 A 到页面 B)传递到另一页面。为此,我使用会话变量(我不能使用临时数据,因为它不适用于负载平衡)。在 Page AI 中设置会话变量。在Page BI中需要检索上面的Session变量。为此,我在页面 B 中使用隐藏字段。我不知道如何将会话变量设置为页面 B 中的隐藏字段。
[HttpPost]
public JsonResult GetFileName(string updatedfileName, string orgfileName)
{
Session["OrgFileName"] = orgfileName;
Session["UpdatedFileName"] = updatedfileName;
var result = myService.getFile(updatedfileName, orgfileName);
return Json(result, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
<div style="display:none" >
<input type="hidden" value="" id="hdnfilename" />
</div>
Run Code Online (Sandbox Code Playgroud) 该页面包含折叠控制,可以对点击进行扩展和收缩.当它扩展时,它应该显示数据库中的记录.我第一次打开页面时工作正常.但是刷新失败了.这在IE中运行良好,仅与Firefox有关.在Firefox中刷新它的失败.我尝试在页面加载时给"hPanelLoaded"赋值为"FALSE".仍然没有工作.似乎刷新FF无法获得"hPanelLoaded"的值,并且它说"$("hPanelLoaded")为null".
这是页面结构.MainPage.aspx正在调用Control> hPanelLoaded.ascx正在调用> hPanelLoaded.js.
知道我在做什么错.
这是代码
@@@@@@@@@@这是在hPanelLoaded.ascx中.@@@@@@@@@@@
<input type="hidden" id="hPanelLoaded" />
Run Code Online (Sandbox Code Playgroud)
@@@@@@@@@@这是在hPanelLoaded.js中.@@@@@@@@@@@
function loadPanel1() {
try {
if ($('hPanelLoaded').value != 'TRUE') {
grdarts.callback();
$('hPanelLoaded').value = 'TRUE'
}
// else {
// alert('INSIDE ELSE');
// $('hPanelLoaded').value = 'FALSE';
// }
}
Run Code Online (Sandbox Code Playgroud) c# ×4
wcf ×3
.net ×2
asp.net ×1
asp.net-ajax ×1
c#-4.0 ×1
gridview ×1
html ×1
javascript ×1
jquery ×1
razor ×1
rest ×1
rtf ×1
service ×1
sql ×1
sql-server ×1
uritemplate ×1