i created a simple web service in asp .net that does some operations:

[WebMethod]
public int Area(int l, int b)
    {
return l * b;
    }

[WebMethod]
public int Perimeter(int l, int b)
{
return 2 * (l +b);
}

and i called it in HTML file, like:

<html>
<head>
<title>WebService Call using HTTP POST</title>
<body>
<form action="http://localhost:56472/WebSite2/Service.asmx/Area" method="POST">
<input name="l">
<input name="b">
<input type="submit" value="Click for Area">
</form>
<form action="http://localhost:56472/WebSite2/Service.asmx/Perimeter" method="POST">
<input name="l">
<input name="b">
<input type="submit" value="Click for Perimeter">
</form>
</body>
</head>
</html>

put this when i click for the result it will be returned as XML:

 <?xml version="1.0" encoding="UTF-8"?>
 <int xmlns="http://tempuri.org/">30</int> 

and what i want is i want the result in HTML not XML, how to do this?

can someone help please?

Thank You :)!

I'm trying to format this HTML so it looks like this: http://iforce.co.nz/i/tryvopws.4xy.png

I can't seem to get it right though! I can make the top part work but then the other sides resize to be really small. I want it to look like the picture.

Any help is appreciated!

<table cellspacing="0" border="0" width="100%">
      <tr class="s4-die">
       <td class="ms-pagebreadcrumb">
       </td>
        <td valign="top" width="100%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="WebPartZone1" Title="loc:Top" />
               &#160;
        </td>
      </tr>
      <tr>
        <td>
         <table width="100%" cellpadding="0" cellspacing="0" style="padding: 5px 10px 10px 10px;">
          <tr>
           <td valign="top" width="60%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left" />
               &#160;
           </td>
           <td>&#160;</td>
           <td valign="top" width="40%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right" Title="loc:Right" />
               &#160;
           </td>
           <td>&#160;</td>
          </tr>
          <tr>
          <td valign="top" width="60%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left2" Title="loc:Left" />
               &#160;
           </td>
           <td>&#160;</td>
           <td valign="top" width="40%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right2" Title="loc:Right" />
               &#160;
           </td>
           <td>&#160;</td>
          </tr>
         </table>
        </td>
      </tr>
    </table>

Good day everyone, I would like to ask you on how to control submitting form if there is no file in fileupload. My code for uploading file is this.

FileInfo fi = new FileInfo(FileUpload1.FileName);
byte[] documentContent = FileUpload1.FileBytes;

string name = fi.Name;
string extn = fi.Extension;

da.InsertCommand.Parameters.Add("@DocumentName", SqlDbType.VarChar).Value = name;
da.InsertCommand.Parameters.Add("@DocumentContent", SqlDbType.VarBinary).Value = documentContent;
da.InsertCommand.Parameters.Add("@DocumentExt", SqlDbType.VarChar).Value = extn;

cs.Open();
da.InsertCommand.ExecuteNonQuery();
cs.Close();

If there is no file selected and the submit button is clicked, I want something that will restrict this to be stored on the database. I don't know what to put in the if-else statement. Please help me.

I have created table in Oracle 11g,

CREATE TABLE "TABLE1" 
(
    "COLUMN1" VARCHAR2(20 BYTE), 
    "COLUMN2" VARCHAR2(20 BYTE)
) 

connect with System.Data.OleDb, the connectionStrings is:

<connectionStrings>
    <add name="DBConnStr" connectionString="Provider=msdaora;Data Source=test;User Id=test;Password=test;" />
</connectionStrings>

and try to insert data into table TABLE1:

private void testInsert()
{
    string sql = "";
    int recordsAffected = 0;

    using (OleDbConnection openCon = new OleDbConnection(constr))
    {
        sql = @"insert into table1 (column1, column2) values (:aaa, :bbb)";
        using (OleDbCommand command = new OleDbCommand(sql))
        {
            command.Connection = openCon;

            command.Parameters.AddWithValue(":aaa", "test");
            command.Parameters.AddWithValue(":bbb", "0123456");

            openCon.Open();
            recordsAffected = command.ExecuteNonQuery(); // <-- error here
            openCon.Close();
        }
    }
}

but get ORA-01008 error at command.ExecuteNonQuery () line. Why is Oracle claiming that not all variables are bound?

If I replace the colon (:) prefix with @, I got ORA-00936 error. And if I remove all prefix, I got ORA-00984 error. What is the correct way to insert data into Oracle table?

Thanks in advance.

I'm having problems with a custom validator I created, in which I test whether data the user inputed is an integer, then I check if it's within a certain range. Currently, no matter what I enter, it just seems to say its not a number, and I don't know why it's causing this. I was wondering if any of you could spot my error.

My code to create all the controls is:

<asp:TextBox ID="txtGuess" runat="server" CausesValidation="True"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" TabIndex="1" Text="Submit" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtGuess" Display="Dynamic" ErrorMessage="Sorry, but this field cannot be blank"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="typeRangeValidator" runat="server" ErrorMessage="DefaultMessage" OnServerValidate="typeRangeValidator_ServerValidate"></asp:CustomValidator>

and the validation function is as follows:

 protected void typeRangeValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        int parsedValue;
        if (!int.TryParse(args.Value, out parsedValue))
        {
            typeRangeValidator.ErrorMessage = "Sorry, but you must provide a number";
            args.IsValid = false;
        }
        else
        {
            int minNum = (int)(Session["minNum"]);
            int maxNum = (int)(Session["maxNum"]);

            if(parsedValue < minNum || parsedValue > maxNum)
            {
                typeRangeValidator.ErrorMessage = "Sorry, but your guess is out of bounds";
                args.IsValid = false;
            }
            else
            {
                typeRangeValidator.ErrorMessage = "Valid!";
                args.IsValid = true;
            }

        }

    }

Both minNum and maxNum are generated from a different page that I transfered from previously. Again, any help would be appreciated. Thanks!

I've been working on a project for a client and had a lot of fun integrating SignalR into the system.

Everything seems to work really well and the client is really excited about how the SignalR gives true real-time feedback for their application.

For the most part everything has gone swimmingly, however I've come into a strange issue I simply cannot pin down.

Everything works great for the following locales:

  1. en-US
  2. en-GB
  3. it
  4. nl

However these languages simply never get a callback from the hub:

  1. fr
  2. de
  3. es
  4. en-ZW - we use English Zimbabwe to check all the strings are translated.

I can step through the code right up until Clients.Client(ConnectionId).update(Result); (where ConnectionId is the correct Connection ID, and Result is the object ready to be serialized, with the first four languages this goes flawlessly and I get my Javascript method with the expected output.

On the last four languages however, the method is fired, but nothing comes through to the other side. Nothing. Zip.

If I replace the Strings.fr.resx file with the default Strings.resx then my site functions as expected, but since the Strings.en-ZW.resx file is identical to Strings.resx (only each string is wrapped in [()]) I doubt that is the issue. I also tried using the fr locale with all unicode translations (`, é, â, etc) removed, but that didn't help.

I've been going over this for almost a full day now and found nothing that would indicate the issue, and the fact that en works fine and en-ZW does not really confuses me.

Anyone have any suggestions?

Hub method:

public class ClientHub : Hub
{
    [...]

    protected void UpdateRecords(List<Int32> ChangedValues) 
    {
        using (var database = new DbContext())
        {
            foreach (Record R in database.Records.Where(Rc => ChangedValues.Contains(Rc.Id))
            {
                SignalRFormattedRecord Serialized = new SignalRFormattedRecord(Record);

                foreach (SavedFilter Filter in SavedFilters.ByRecord(Record))
                {
                    // Next line is always called.
                    Clients.Client(Filter.ConnectionId).updateRow(Serialized);
                }
            }
        }
    }

    [...]
}

Javascript:

$.connection.clientHub.updateRow = function(value) {
    debugger;
    // update code works in all languages except FR, DE, ES and en-ZW.
}

$.connection.start();

Within my web application I have registered Google as a single sign-on provider:

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions {
    ClientId = "8765.......apps.googleusercontent.com",
    ClientSecret = "Secret"
})

My app doesn't allow users to sign-up/register (instead their accounts are created by an administrator, but they can later link their account up with Google).

In my "Sign in with Google" controller, I am trying to issue a Challenge() to redirect to Google. This might not be thecorrect approach:

string redirectUri = "http://localhost:55262/SSO/Google/ProcessToken"; // actually created in code, but shown as string for clarity
AuthenticationProperties properties = new AuthenticationProperties();
properties.RedirectUri = Server.UrlEncode(redirectUri);
Context.GetOwinContext().Authentication.Challenge(properties, "Google");

This correctly sends the user to Google, but Google then presents Error: redirect_uri_mismatch, saying that:

The redirect URI in the request: http://localhost:55262/signin-google did not match a registered redirect URI.

I've seen this error before when the return URI collection in the Google control panel does not contain the redirect_uri specified.

If I debug in VS2015, I can see the redirect_uri property being set correctly in the AuthenticationProperties, but it seems that OWIN/Katana is not passing it to Google. Instead, when I hit Google, the return_uri is the default one used by OWIN/Katana. The one I set is being ignored.

The Google request details seem to confirm this:

scope=openid profile email
response_type=code
redirect_uri=http://localhost:55262/signin-google

What am I doing wrong here please? Should I not be using Challenge() to allow users to link up their local application account with Google?

The Situation

I have come across some very suspicious PUT and GET requests in my IIS server logs. After Googling the requesters address, I have found information linking the IP's to known hacking teams. After each PUT there is an immediate GET for the same resource that was attempted to be uploaded to my server.

Question 1: Would this be considered a remote code execution attack?

Additional Testing Completed By Me:

The IIS logs show that the response given for the PUT request was 412 'Invalid file type all files are not uploaded'

I have turned on Failed Request Tracing and attempted to upload text files using CURL and this is the same response I am provided with and was not able to upload a file.

Question 2: What can I do to help prevent these type of attacks from being successful?

I can turn on IIS request filtering, but I am concerned that if I deny PUT my IIS application may be negatively impacted for any future web services.

I am developing a web app in ASP.NET with c#.

The top page of the app is available to everyone, so we use Anonymous authentication. There is a resource at a lower level which must be protected by smartcard + PIN.

I have set up Accept Client Certificates in the IIS console for this directory and I get the usual OS PIN prompt when I access that resource. So far so good.

However, all subsequent access to that resource then succeeds and I am never prompted for the PIN again.

The question: How can I configure (in IIS or web.config or even in c#) the page so that it always prompts me for PIN?

Thanks

i only have a folder open and visual studio, its loads all the files and throws this error, i thought there must have been a memory constraint and restarted the system but that did not help either. So i guess my question to keep it simple, is there a way to actually free up memory on visual studio??

enter image description here

i am using this code in my app

  Int32 nn = int.Parse(textBox.Text); // the function parameter
VISITE v = me.VISITEs.FirstOrDefault(a => a.VINUM == nn);
            DateTime d = (DateTime)v.DATEVIS;
            Int32 p = (Int32)v.PANUM;




  var numberGroups =
        from n in me.VISRUBs.Where(a => a.VISANA.VISITE.DATEVIS <= d && a.VISANA.VISITE.PANUM == p)
        group n by n.RUBRIQUE into g

        select new
        {

            RemainderCHAPLIB = g.Key.ANALYSE.CHAPITRE.LIBELLE,
            RemainderLIB = g.Key.LIBELLE,

            RemainderRUNUM = g.Key.RUNUM,
            vals = (from vlist in g.OrderByDescending(a => a.VISANA.VISITE.DATEVIS)
                    select vlist.VALEUR)
        };


            var lst = from n in numberGroups.
            ToList().
            Where(a => a.RemainderLIB != null)

                      select new ResultClass
                      {
                          CHAP = n.RemainderCHAPLIB,
                          RUB = n.RemainderLIB,

                          VAL = n.vals.FirstOrDefault(),
                          ANT = n.vals.Skip(1).FirstOrDefault()

                      };

the queries run very very slowly in aspnet web service, about (60 sec !)

and slow in WPF (about 5/6 sec)only first time , after that it execute super fast (0.1s)

after some searching i have found the compiled queries , but all examples i have found take a single select query

so my questions :

  • how to turn this statment code into a compiled query please ?

  • and any explanations on the huge performance difference between Asp.net and desktop ?

  • any other tricks i may do to get fast queries ?

thanks.

I'm trying to insert all the ith values to table called AB_Product_vs_Field but its only insert last i values only

this is that LINQ query

for (int i = 0; i < product.ListProductFields.Count; i++)
{
   insertproductvalue.Product_ID = product.Product_ID;
   insertproductvalue.Field_ID = product.ListProductFields[i].ProductFieldID;
   insertproductvalue.Field_Value_EN = product.ListProductFields[i].Field_Value_EN;                         
};

db.AB_Product_vs_Field.Add(insertproductvalue);
db.SaveChanges();

How to insert all of those rows one by one

I am pretty advanced in C# but a newcomer in the world of ASP.NET.

My HomeController.cs:

public ActionResult Index()
{
    // tuple -> item1 = key string / item2 = assigned list
    var configList = new List<Tuple<string, List<string>>>();
    configList = fillItWithSomeData(..)
    ViewBag.ConfigSettings = configList;

    return View();
}

My Index.cshtml:

<div>
    <div class="row">
        @foreach (var elements in ViewBag.configSettings)
        {
            <div class="col-md-8 checkbox">
                /*I NEED A BUTTON HERE*/
                <label>
                    <input type="checkbox">@elements.Item1
                </label>
            </div>
            foreach (var listElement in elements.Item2)
            {
                <div class="col-md-8 col-md-offset-1 checkbox">
                    <label>
                        <input type="checkbox">@listElement
                    </label>
                </div>
            }
        }
    </div>
</div>

Every key string in my list contains a list of strings. (look at var configList) In my view I want to have a button for each key string which should be able to open or close the assigned list of the respective key string. I currently use ASP.NET-MVC. How can I program that? In C# or do I need to use JS for that? I really have no idea. Thanks in advance.

I have following viewpage , Its form that contains text field, dropdowns and Rich text areas.

enter image description here

this is the cshtml code for that viewpage

I want to restrict Product_ID, ProductTypeID, ProductCategoryID, Subsidary_ID to first page and from Product title onward add to second page .

like this view

enter image description here

How can I do this ?

As explained in title, How can I select Asp syntax when creating new MVC 5 project in visual studio 2015?

As I remember; in previous Visual Studio versions I could select ASP or Razor Syntax.

How can I do it in Visual Studio 2015 community edition?

I am trying to concatenate a hardcoded string value("Element") with the knockout text binding as below. However, the output is not as expected. What am I doing wrong? Should I use the attr binding to concatenate the string value?

.cshtml

<div class="timeline-list-items" data-bind="attr: { memberSlot: MemberSupport }">
    <h6 data-bind="text:Title()+'Element'"></h6>
</div>

A very basic question: how can I easily view the contents of a ViewBag while debugging ASP.NET MVC controllers in Visual Studio?

As a workaround, I use temporary variables:

string tmp = ViewBag.MyData;

So, the problem is that viewing ViewBag.MyData directly is difficult, tmp is easy.

What is the best approach to keeping two separate sets of views in one application?

I need to create two websites which have different frontend layouts, but have almost identical code base (admin area, controller logic, etc). There are supposed to be two build configurations that decide which layout to use.

I have a url that is hold the complete path of my SSRS Report . In C# i want to break the url in multiple string

http://Mydatabase-live/ReportServer?%2fADMIN%2fSTATS+-+SCHEDULE&TEAMNM=2015 TERRIER JV&rs:Command=Render&rs:Format=PDF

Here i want to break this url into part-1 http://Mydatabase-live/ReportServer part-2 ADMIN/STATS-SCHEDULE and part-3 TEAMNM

I have tried SQL server configuration manager settings like TCP/IP port settings, have set default port to 1433 but still not able to connect with database. plz help me. my connection string as follows

Data Source=192.168.1.71\SQLEXPRESS;User ID=sa;Password=ash0989;Initial Catalog=estimate;

user-table
----------
name        email        start_date      end_date       status
abc        abc@abc.com   1/10/2015      1/11/2015     Expired
xyz        xyz@abc.com   5/10/2015      5/11/2015     Expired
pqr        pqr@abc.com   17/10/2015     16/11/2015    Active

I want functionality for sending mail for all end_date is today.
If time has ended the send mail before week, day before, day and day after.

For ex.

Send mail for day 16/11/2015 then also send before week, day before, day and day after, like 9/11/2015, 15/11/2015, 16/11/2015, 17/11/2015.

Note - This functionality will be automatically call WebMethod and check from database and send mails on every night 12:00 AM.