Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8124165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:22:57+00:00 2026-06-06T06:22:57+00:00

As windows 8 metro style javascript/html5 apps cannot communicate directly with database, I want

  • 0

As windows 8 metro style javascript/html5 apps cannot communicate directly with database, I want to create a c# wcf service connected with SQL server and calling it in metro style javascript/html5 app for data storing and retrieving.

I have created a c# wcf service application in Visual Studio 2012 RC and hosted on local windows 8 release preview system. But i am unable to connect wcf service with my metro app.

Below is my wcf service application code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService2
{
    [OperationContract]
    [WebGet(UriTemplate = "/Add/{Number1}/{Number2}", RequestFormat = WebMessageFormat.Json,
   ResponseFormat = WebMessageFormat.Json
                                                    )]
    int Add(string Number1, string Number2);
}
}

And

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
public class Service1 : IService2
{
    public int Add(string Number1, string Number2)
    {
        int num1 = Convert.ToInt32(Number1);
        int num2 = Convert.ToInt32(Number2);
        return num1 + num2;
    }      



}
}

And

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>

      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>

      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>     
</behaviors>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
    multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>

<directoryBrowse enabled="true"/>
</system.webServer>

</configuration>

Below is my code of calling wcf in metro app:

var Number1  = document.getElementById('TextboxFirstNumber');
var Number2  = document.getElementById('TextboxSecondNumber');
var ResultSpan  = document.getElementById('SpanResult');
var ButtonToAdd  = document.getElementById('ButtonAdd');
ButtonToAdd.addEventListener('click',  function  ()  {
    var baseURl = "http://localhost:52653/Service1.svc/Add/";
    var url  = baseURl+Number1.value+"/"+Number2.value;  
    WinJS.xhr({ url: url  }).then(function  (r)  {
        var result  = JSON.parse(r.responseText);
        ResultSpan.innerHTML  = result; 
    });
}); 

My metro app exits with following error:

{"exception":null,"error":{},"promise":{"_oncancel":null,"_nextState":null,"_state":{"name":"error","done":null,"then":null},"_listeners":null,"_value":{},"_isException":false,"_errorId":2},"id":2}

Please tell me what i am doing wrong here…
or is there any way to communicate metro javascript/html5 app with sql server database.

Thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:23:00+00:00Added an answer on June 6, 2026 at 6:23 am

    I have done it by creating a JSON-Rest-WCF Service, connect it with sql server and call this service from metro app through below method.

    WinJS.xhr({ url: url})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to build a metro-style-app with Javascript and when I run the Windows
I have a problem understanding one style definition in Windows 8 metro apps. When
I decided to have a go at building Windows Metro style apps with the
I'm trying to create some primitive imitation of the Windows Metro style application. What
I have installed Windows 8 and Visual Studio 11 to develop metro style apps.
I've just started to use new VS2012 and Windows 8 and create C# Metro-style
I am working on an app in Windows 8 Metro Style app. I need
I found that, WebView control (For Windows 8 Metro style app) is the one
I am trying to use Windows.Media.Capture.CameraCaptureUI() of Metro Style app in WPF application in
In a Windows 8 Metro App I want the ListViewItems/Tiles to open a link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.