处理此请求时发生错误 [英] An error occurred while processing this request

查看:146
本文介绍了处理此请求时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我不确定为什么会出现这个错误请求...



这里是代码的大部分内容。



它说的是这行代码的错误

Basically, Im not sure why this error request is coming up...

here is the bulk of the code.

It's saying the error on this line of code

Customer customer = (context.Execute<Customer>(new Uri("GetAuthenticatedCustomer", UriKind.Relative), "POST", false, opParams)).FirstOrDefault();





请光一点!谢谢





Please shed some light! Thanks

private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(emailAddressTextbox.Text) && !string.IsNullOrEmpty(passwordTextbox.Text))
            {
                Uri svcUri = new Uri("http://localhost:29875/iShop.svc");

                iShopEntities context = new iShopEntities(svcUri);

                UriOperationParameter[] opParams = new UriOperationParameter[2];

                opParams[0] = new UriOperationParameter("EmailAddress", emailAddressTextbox.Text);
                opParams[1] = new UriOperationParameter("Password", passwordTextbox.Text);

                Customer customer = (context.Execute<Customer>(new Uri("GetAuthenticatedCustomer", UriKind.Relative), "POST", false, opParams)).FirstOrDefault();
                Seller seller = (context.Execute<Seller>(new Uri("GetAuthenticatedSeller", UriKind.Relative), "POST", false, opParams)).FirstOrDefault();

                if (customer != null)
                {
                    MessageBox.Show("Welcome " + customer.FirstName);
                    //MainWindow mainWindow = new MainWindow();
                    //mainWindow.Show();

                    //CustomerOrder customerOrder = new CustomerOrder();
                    //customerOrder.customer = customer;
                    //customerOrder.Show();

                }
                else if (seller != null)
                {
                    MessageBox.Show("Welcome " + seller.FirstName);
                }
            }
            else
            {
                MessageBox.Show("Please specify email and password");
            }
        }

推荐答案

这篇关于处理此请求时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆