|
Venturing into the Web API arena after years using WCF so!
If I have a service built on 4.51 serving up Json objects can that be consumed by a WPF client using 4.0
Is it reasonable to create a Web API service WITHOUT MVC, this will be consumed by various clients including MVC and WPF bit I want them in a separate projects.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I assume that the last statement meant to be a question...
It makes all the senses to separate common functionality from other layers. There is no technical problem to create pure WEB API projects (the only problem is that you will have to build it manually from scratch or by cleaning a project created by the wizard)...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Almost all examples are for 4.5(1) and include MVC, as I know very little about MVC I struggle to separate the them. One article I was working through requires the project to be published to test it, painful.
What I am really looking for is an example of a plain Web API project consumed by a WPF client.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
There is a ways to create an WEB API only project (in VS 2013), but I never checked it... Choose Empty ASP.NET Web Application, int the 'Add folders and core references for:' section choose WEB API...
If 4.5 does not fit you, you can open project properties and change target framework...(no idea what wrong with 4.5, I do use 4.5.2)
These two links may help you on how to access such a WEB API from WPF:
http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client[^]
Calling ASP.NET WebAPI using HttpClient[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hi all,
We recently upgraded our web application from Windows server 2003 to Windows server 2008. Everything works good except that the Gridview footer controls' id are generating different. This is causing some external javascript failure. The Gridview code is:
<asp:UpdatePanel ID="UPSposors" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="grvSponsors" Visible="true" AutoGenerateColumns="false" HeaderStyle-Font-Names="Verdana"
HeaderStyle-Font-Size="9pt" PageSize="5" ShowFooter="true" TabIndex="9" runat="server"
OnRowCancelingEdit="grvSponsors_RowCancelingEdit" OnRowEditing="grvSponsors_RowEditing"
OnRowUpdating="grvSponsors_RowUpdating">
<Columns>
<asp:TemplateField HeaderStyle-Width="100px" SortExpression="SponsorType" HeaderText="Contact Type">
<EditItemTemplate>
<asp:DropDownList ID="ddlEditSponsorType" runat="server" Width="99px" Font-Names="Verdana"
Font-Size="8pt">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSponsor" runat="server" Text='<%# Bind("SponsorType") %>' Font-Names="Verdana"
Font-Size="8pt" /></a>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlAddSponsorType" runat="server" Width="99px" Font-Names="Verdana"
Font-Size="8pt" TabIndex="13">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvAddSponsor" runat="server" Display="Dynamic" ErrorMessage="Business Contact-Contact Type is required."
InitialValue="" Enabled="false" ControlToValidate="ddlAddSponsorType"><strong>!</strong></asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField FooterText="<U><a style='cursor:hand;font-family:Verdana;font-size:8pt;padding:2px;' TabIndex ='14' id='aAdd' onclick='TriggerAddSponsor();' >Save</a></U>"
ShowDeleteButton="true" ShowEditButton="true" HeaderStyle-Width="125px" CausesValidation="false"
ControlStyle-Font-Names="Verdana" ControlStyle-Font-Size="8pt" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
The generated HTML control in Windows Server 2003 is:
<td>
<select name="tcGeneral$tpGeneral$grvSponsors$ctl03$ddlAddSponsorType" id="tcGeneral_tpGeneral_grvSponsors_ctl03_ddlAddSponsorType" tabindex="13" style="font-family:Verdana;font-size:8pt;width:99px;">
<option value="">Select</option>
<option value="BUS">Business</option>
<option value="IT">IT</option>
<option value="SP">Sponsor</option>
</select>
<span id="tcGeneral_tpGeneral_grvSponsors_ctl03_rfvAddSponsor" style="color:Red;display:none;"><strong>!</strong></span>
</td>
The generated HTML control in Windows Server 2008 is:
<td>
<select name="tcGeneral$tpGeneral$grvSponsors$ctl03$ddlAddSponsorType" id="tcGeneral_tpGeneral_grvSponsors_ddlAddSponsorType" tabindex="13" style="font-family:Verdana;font-size:8pt;width:99px;">
<option value="">Select</option>
<option value="BUS">Business</option>
<option value="IT">IT</option>
<option value="SP">Sponsor</option>
</select>
<span id="tcGeneral_tpGeneral_grvSponsors_rfvAddSponsor" style="display:none;"><strong>!</strong></span>
</td>
As you can see the id generated for W2K3 server has "ctl03" in it but the W2K8 does not. This is causing our javascripts to fail. On my laptop running IIS7.5 the id has "ctl03" its just on the windows server 2008 that is missing it. Am I missing some kind of setting or deployment?
Thank you for any help in advance,
AJ
|
|
|
|
|
|
Thank you Richard. That solved the problem. I did set the framework to 4.0 however on my and other developer's localhost the client id was generating as it always did. Only when we deployed it to Windows 2008 server that we ran into this issue. Any idea why the client id is generating as "AutoID" on local machines but not on the W2K8 server?
Thank you again for your help.
AJ
|
|
|
|
|
That's odd. Are you sure your local copy was running under IIS, and not the Visual Studio web-server?
Also, have a look at the web.config files; it's possible that your local file was upgraded to .NET 4.0 and had the application-wide default set to AutoID , whereas the deployed file didn't have that setting.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My local copy is running under VS Web-server but I thought since the project is set to target Framework 4 (in project properties -> Compile -> Advanced Compiler Settings) that it would behave same way as it would on the server running under IIS.
Why does web-server not follow the same rule/logic as IIS when it comes to targeting .net framework.
Thanks for your input.
AJ
|
|
|
|
|
With those settings, it should be using .NET 4 for your local copy.
How about the web.config file? Are there any differences between your local copy and the one on the server?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are right. Here is what I found in web config of the developers:
<pages controlrenderingcompatibilityversion="3.5" clientidmode="AutoID">
However this was not updated in the web configs of the servers in all environments.
Good call,
Thanks you.
|
|
|
|
|
When I load my page it shows error:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'UserInfoaa' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 176: }
Line 177:
Line 178: public virtual UserInfoaa UserInfoaa {
Line 179: get {
Line 180: return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c367d58a\7b408850\App_Code.d_07k52h.1.cs Line: 178
My default.aspx Code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using System.Text;
namespace WebApplication2
{
public partial class Dfault : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void submit_Click(object sender, EventArgs e)
{
MembershipCreateStatus createStatus;
MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text, null, null, true, out createStatus);
saveprofile();
}
public void saveprofile()
{
ProfileCommonaa Profile = new ProfileCommonaa();
Profile.UserInfoaa.Name = name.Text;
Profile.Save();
}
}
}
My UserInfoaa class code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2
{
[Serializable()]
public class UserInfoaa
{
#region variables
private string name;
#endregion variables
#region Properties
public string Name
{
get { return name; }
set { name = value; }
}
#endregion Properties
#region Constructors
public UserInfoaa()
{
}
public UserInfoaa(string _name)
{
name = _name;
}
#endregion Constructors
}
}
Class1 for ProfileCommonaa is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Text;
using System.Web.Security;
using System.Web.UI;
namespace WebApplication2
{
public class ProfileCommon : System.Web.Profile.ProfileBase
{
public virtual UserInfoaa UserInfoaa
{
get
{
return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
}
set
{
this.SetPropertyValue("UserInfoaa", value);
}
}
public virtual ProfileCommonaa GetProfileaa(string username)
{
return ((ProfileCommonaa)(ProfileBase.Create(username)));
}
}
}
Please help! thanks in advance
modified 7-Jul-14 0:31am.
|
|
|
|
|
1. do not repost your questions all over the forums - pick the best fitting and stay with it!
2. remove all the unrelated code - it is extremely hard to follow such long listing
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Please let me know the solution I am new in asp.net
|
|
|
|
|
That stuff about ProfileCommonaa is not defining a class ... you might want to look closer at that
|
|
|
|
|
V.sory this mistake i have done at the time of posting this question.
|
|
|
|
|
I'm getting this error:
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
Here is my Entity Framework connection string:
<add name="EFDataModelEntities2" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=HOLDORF-PC\SQL_2008_R2;initial catalog=EFDataModel;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
And here is my Model connections:
<EntityContainer Name="EFDataModelEntities2" annotation:LazyLoadingEnabled="true">
<EntityContainerMapping StorageEntityContainer="EFDataModelModelStoreContainer" CdmEntityContainer="EFDataModelEntities2">
Thannks,
Steve Holdorf
|
|
|
|
|
I just looked at the error details and this is what I'm getting:
{"The provider did not return a ProviderManifestToken string."}
I am hitting Google as well.
As always, thanks you guys!
modified 5-Jul-14 16:56pm.
|
|
|
|
|
Also are my connection strings:
SQL
<add name="DbConnectionString" connectionString="Data Source=HOLDORF-PC\\SQL_2008_R2;Initial Catalog=EFDataModel; Integrated Security=True" providerName="System.Data.SqlClient" />
EF
<add name="EFDataModelEntities2" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=HOLDORF-PC\SQL_2008_R2;initial catalog=EFDataModel;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
|
|
|
|
Seems alright...
Have test your connection visual studio sql manager
Sankarsan Parida
|
|
|
|
|
I can open the database just fine with VS. I'm stumped. Any help would be great!
|
|
|
|
|
plz remove
Integrated Security=SSPI;"
Then try again
Sankarsan Parida
|
|
|
|
|
Hi all,
am working on Dynamic Menu its working fine in English when i convert this same menu in Arabic its working fine but the sub menu has some margin...if we set the margin then again for 2nd main menus submenu is not coming in order...
www.dreamcom.ae (This is for english working good)
www.dreamcom.ae/Ar/Index.aspx (This is for Arabic which is not working)
<asp:Menu ID="menuBar" StaticEnableDefaultPopOutImage="False" runat="server" Orientation="Horizontal"
onmenuitemclick="menuBar_MenuItemClick" DynamicHorizontalOffset="2" Font-Size="18px"
BackColor="#669903" ForeColor="White" StaticSubMenuIndent="100%" Font-Bold="True" Height="56px" vertical-align="top" top="50px"
margin="0px" position="static" BorderStyle="None" DynamicSelectedStyle-BorderStyle="None" BorderColor="#7ab802" CssClass="menucss">
<DynamicHoverStyle BorderStyle="Solid" BorderWidth="0px" BackColor="#7ab802" ForeColor="White" />
<DynamicMenuItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="0px" Font-Bold="true" Font-Size="17px" HorizontalPadding="6px" VerticalPadding="6px" />
<DynamicMenuStyle BorderColor="#669903" BorderStyle="Solid" BorderWidth="1px" BackColor="#669903" CssClass="menucss"/>
<DynamicSelectedStyle BorderColor="#3094FC" BorderStyle="Solid" BorderWidth="0px" ForeColor="#3094FC" BackColor="#5D7B9D" CssClass="menucss" />
<StaticHoverStyle BorderColor="#669903" BorderStyle="Solid" BorderWidth="0px" BackColor="#7ab802" ForeColor="#ffffff" CssClass="menucss" />
<StaticMenuItemStyle ForeColor="White" BorderStyle="Solid" BorderWidth="0px" Font-Size="14px" HorizontalPadding="15px" VerticalPadding="20px" CssClass="menucss" />
<StaticSelectedStyle BorderColor="#5CB8FF" BorderStyle="Solid" BorderWidth="1px" ForeColor="#fafafa" BackColor="#5CB8FF" />
</asp:Menu>
this code am using in both english and in arabic.....but in arabic am using style="direction:rtl;" hence it the direction of the content will change...
and am fetching english and arabic datas are fetch from database..
Kindly help me out...am trying from long time..
Thanks.
|
|
|
|
|
I have a page that performs a callback and I'm trying to handle the situation where the session has expired, but the callback is still being invoked.
I'm using the following code in my Global.asax
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim httpApp As HttpApplication = Context.ApplicationInstance
Dim httpEx As HttpException = httpApp.Server.GetLastError
If (httpEx IsNot Nothing) Then
If (httpEx.WebEventCode = System.Web.Management.WebEventCodes.AuditInvalidViewStateFailure Or _
httpEx.WebEventCode = System.Web.Management.WebEventCodes.InvalidViewState Or _
httpEx.WebEventCode = System.Web.Management.WebEventCodes.InvalidViewStateMac Or _
httpEx.WebEventCode = System.Web.Management.WebEventCodes.RuntimeErrorViewStateFailure) Then
HttpContext.Current.ClearError()
Response.Redirect("~/MyErrorPage.aspx", True)
End If
End If
End Sub
The problem is that it is not redirecting to my error page.
I'm testing this out on an IIS7 server and I force the error by stopping, then restarting the application pool on the server in between requests. Maybe I'm performing the wrong type of test.
Shouldn't this re-direction work?
Am I performing the correct type of test ?
Ugh.
|
|
|
|
|
The fact that your session is went done will not stop the web page to work perfectly correct! ViewState and all the related info was posted to the client (in hidden fields) and will be reused on the next post-back. The only problem with session down is authentication and data you stored on the session (ASP.NET engine do not store nothing on the session by default)...
More! You are using down-casting here which can be very dangerous...Who told you GetLastError will return an HttpException! Maybe it's a SystemException or a plain Exception?!
Also, if you read explanations of the error codes you use, you will see that none of them is connected to session end - http://msdn.microsoft.com/en-us/library/system.web.management.webeventcodes(v=vs.110).aspx[^]
If you want to catch session end - and maybe set a flag for later use - see for Globla.asax...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|