我刚学习wcf,目前已经走到了这一步.
CS档案:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace wcfLib
{
[ServiceContract]
public interface IfaceService
{
[OperationContract]
int wordLen(string word);
}
public class StockService : IfaceService
{
public int wordLen(string word)
{
return word.Length;
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,当我试图运行它时,它会弹出一个错误:
WCF服务主机找不到任何服务元数据...
知道它可能是什么?
配置文件:
<system.serviceModel>
<services>
<service behaviorConfiguration="wcfLib.Service1Behavior" name="wcfLib.Service1">
<endpoint address="" binding="wsHttpBinding" contract="wcfLib.ser">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/wcfLib/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfLib.Service1Behavior"> …Run Code Online (Sandbox Code Playgroud) Javascript |和||Javascript有什么区别?
而且,&和之间有什么区别&&?
我试图点击弹出如下所示,但它不起作用.请帮忙
public void btnSubmit_Click(Object o, EventArgs e)
{
if (checkFileExists(Convert.ToString(fileInfo)))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Msg", "<script type=\"text/javascript\" language=\"javascript\">function showMsg(){return confirm(\"This image name already exists, do you want to replace it?\");}</script>", true);
btnSubmit.OnClientClick = "return showMsg()";
}
if (something else)
{
// It does whatever is here but never pops the question above
}
}
Run Code Online (Sandbox Code Playgroud)
在我的按钮上
<asp:Button class="Button" ID="btnSubmit" CausesValidation="True" Text="SUBMIT" runat="server"
OnClick="btnSubmit_Click"></asp:Button>
Run Code Online (Sandbox Code Playgroud) 如何在不获取子表中的行的情况下获取表中的所有行?
var rows = $('tr', tbl);
Run Code Online (Sandbox Code Playgroud)
这将返回所有<tr>标记,包括子表中的所有行.
我写了一个方法,它收集了一些项目(价格项 - 每个项目都有一个数量和一个代码),然后按代码对它们进行分组,然后返回一个IDictionary,其中键是项目的代码,值是组带有该代码的项目(希望有意义!)
这是方法的实现:
public IDictionary<string, IEnumerable<PriceDetail>> GetGroupedPriceDetails(IEnumerable<PriceDetail> priceDetails)
{
// create a dictionary to return
var groupedPriceDetails = new Dictionary<string, IEnumerable<PriceDetail>>();
// group the price details by code
var grouping = priceDetails.GroupBy(priceDetail => priceDetail.Code);
// foreach grouping, add the code as key and collection as value to the dictionary
foreach (var group in grouping)
{
groupedPriceDetails.Add(group.Key, group);
}
// return the collection
return groupedPriceDetails;
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试重构这个使用ToDictionary,如下所示:
// group the price details by code and return
return priceDetails.GroupBy(priceDetail => priceDetail.Code) …Run Code Online (Sandbox Code Playgroud) 我有一个混合的.NET和本机代码控制台应用程序.由于Visual C RunTime Library致命错误,应用程序进程终止.即使我使用以下内容,托管代码也不会捕获本机异常:
AppDomain.UnHandledExption += ... RuntimeCompatibilityAttribute(WrapNonExceptionThrows = true)在AssmblyInfo文件中标记.我还可以做些什么?
我开始使用简单的WCF服务时有点失落.我有两种方法,我想向世界公开一个,第二个我想限制某些用户.最终,我希望能够使用客户端应用程序来使用受限制的方法.到目前为止,我可以匿名访问这两种方法:
C#代码
namespace serviceSpace
{
[ServiceContract]
interface ILocationService
{
[OperationContract]
string GetLocation(string id);
[OperationContract]
string GetHiddenLocation(string id);
}
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class LocationService : ILocationService
{
[WebGet(UriTemplate = "Location/{id}")]
public string GetLocation(string id)
{
return "O hai, I'm available to everyone.";
}
// only use this if authorized somehow
[WebGet(UriTemplate = "Location/hush/{id}")]
public string GetHiddenLocation(string id)
{
return "O hai, I can only be seen by certain users.";
}
}
}
Run Code Online (Sandbox Code Playgroud)
组态
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" …Run Code Online (Sandbox Code Playgroud) 我有一个在我的IIS6(XP专业版SP2)中运行的.NET 2.0网站(VB)和一个托管ASMX Web服务的.NET 3.5(在IIS的ASP.NET选项卡下配置为.NET2).
在Chrome中,我可以调用ASMX并成功调用Web方法.但是,在使用.NET 2.0网站调用代码中的Web方法时,我得到:
请求失败,HTTP状态为401:未授权.
我该如何解决这个问题?
c# ×6
.net ×2
wcf ×2
.net-3.5 ×1
asp.net ×1
cohesion ×1
javascript ×1
jquery ×1
linq ×1
messagebox ×1
oop ×1
operators ×1
refactoring ×1
web-services ×1
winforms ×1