Start VLC from asp.net webpage - asp.net

I have the following code:
protected void VLC_Click(object sender, EventArgs e)
{
SecureString password = ConvertStringToSecureString("[password]");
string domain = "";
Process.Start(#"C:\Program Files\VideoLAN\VLC\vlc.exe ", "[username]", password, domain);
}
private SecureString ConvertStringToSecureString(string s)
{
SecureString secString = new SecureString();
foreach (char c in s.ToCharArray())
{
secString.AppendChar(c);
}
return secString;
}
linked to a button on an aspx page running on IIS on my Vista machine. When I click the button in the browser, I can see the process start in task manager but shortly after the process terminates and no vlc window appears at any point.
Is there any way to have the button trigger vlc just as if I was clicking on the .exe in Windows?

I hope you don't expect VLC appearing on the client machine when you do a Process.Start on the server in an ASP.NET application.

It should work if the user that runs asp.net is able to interact with the desktop. On windows services there is a setting one can check for this.

Related

Windows phone app crashes while communicating to wcf service without internet connection

I have added the web service to my WPF windows phone store app, when i run my app in emulator it works, but sometime it get creshes cause lack of internet connectivity.
i'm checking my emulator IMEI is registerd or not in database using WCF service on main_pageload event
my code looks like this
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
SchoolWebService.SchoolAppWebServiceSoapClient proxy = new SchoolAppWebServiceSoapClient();
proxy.CheckIMEIRegisteredOrNotCompleted += new EventHandler<CheckIMEIRegisteredOrNotCompletedEventArgs>(proxy_CheckIMEIRegisteredOrNotCompleted);
proxy.CheckIMEIRegisteredOrNotAsync(strIMEI);
}
in this service im checking the mobile IMEI registerd or not. i have checked by debugging the app it goes upto proxy.CheckIMEIRegisteredOrNotAsync(strIMEI);
when it leave the context it throuw the error
An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.ni.dll but was not handled in user code
please suggest me some advice,,,thanks in advance
To check if the Internet connection is available I just simply create a method to check it and execute it then application is launching or page is loading. This method I create in App.xaml.cs:
public bool CheckInternetConnection()
{
bool connection = true;
ConnectionProfile currentConnection = NetworkInformation.GetInternetConnectionProfile();
if (currentConnection == null)
{
connection = false;
}
return connection;
}
Then in some page_loaded event I execute it:
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
bool connection = ((App)Application.Current).CheckInternetConnection();
if (connection == false)
{
MessageBox.Show("Internet connection is not available", "Internet connection", MessageBoxButton.OK);
Application.Current.Terminate();
}
}
Now then a client don't have the Internet connection available it won't crash, but it will show a message for the user. I hope it will help.

System.Net.Sockets.SocketException: A system call has failed

I have the following code snippet that run with IIS Express of VS2012. It is able to send out email and working fine with smtp server.
Then deployed it as New Application on IIS 7. When I run it, I am getting the error “System.Net.Sockets.SocketException: A system call has failed 11.29.83.49:25” .
Do you have any idea what causing the error?
Do I miss something to configure IIS server to work with smtp server?
protected void Page_Load(object sender, EventArgs e)
{
System.Net.Mail.MailMessage _message = new System.Net.Mail.MailMessage();
_message.Subject = "Hi Testing";
_message.SubjectEncoding = System.Text.Encoding.UTF8;
_message.From = new System.Net.Mail.MailAddress("sender#gmail.com","Test");
_message.To.Add(new System.Net.Mail.MailAddress("receiver#gmail.com", "Test"));
System.Net.Mail.AlternateView _content_view = System.Net.Mail.AlternateView.CreateAlternateViewFromString("Message Body");
_message.AlternateViews.Add(_content_view);
sendEmailMessage(_message);
}
public void sendEmailMessage(System.Net.Mail.MailMessage message)
{
getClientFromConfig().Send(message);
}
private static System.Net.Mail.SmtpClient getClientFromConfig()
{
System.Net.Mail.SmtpClient _client = new System.Net.Mail.SmtpClient();
_client.Host = "host name/ip here";
_client.Port = 25;
return _client;
}
Could anyone please suggest to get it work?
I think the reason is firewall.
Open IIS Manager ->Application Pool and select your pool then click advanced settings.
Change your Identity as
Network Service
-below the process model

CRM 2011 Online via an ASP.net application does not work, same code via Console Application Works -> "Authentication Failure"-error

I'm trying to connect to a CRM 2011 Online environment. I'm able to connect via a "Console Application", but when I'm trying to connect via an "ASP.net"-application with the same code, it doesn't work, it gives me the "Authentication Failure"-error ({"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."}).
Is there something special we need to do to make it work on an "ASP.net" environment. I tested out several solutions I found on the internet, but all gives me the same error.
A "code"-snippet of my simplified code:
private static ClientCredentials GetDeviceCredentials()
{
return Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
}
protected void Button1_Click(object sender, EventArgs e)
{
//Authenticate using credentials of the logged in user;
string UserName = "*****"; //your Windows Live ID
string Password = "*****"; // your password
ClientCredentials Credentials = new ClientCredentials();
Credentials.UserName.UserName = UserName;
Credentials.UserName.Password = Password;
Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
//This URL needs to be updated to match the servername and Organization for the environment.
Uri OrganizationUri = new Uri("https://*****.crm4.dynamics.com/XRMServices/2011/Organization.svc"); //this URL could copy from Setting --> Developer Source
Uri HomeRealmUri = null;
//OrganizationServiceProxy serviceProxy;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))
{
IOrganizationService service = (IOrganizationService)serviceProxy;
OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
var theAccounts = orgContext.CreateQuery<Account>().Take(1).ToList();
Response.Write(theAccounts.First().Name);
}
}
I tried several things, like deleting the content of "LiveDeviceID"-folder an re-running the device registration tool. but is weird that it works in the "console application" but not on my "asp.net"-solution...
PS : I am able to generate the "context"-file via crmsvcutil.exe /url:https://org.crm4.dynamics.com/XRMServices/2011/Organization.svc /o:crm.cs /u:username /p:password /di:deviceUserName /dp:devicPWD
Is there any particular reason you have
Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
You shouldn't need that line for windows live authentication.
Even with that the code seems valid so it is something to do with the Device Registration. I suggest rather than just call it directly like you have
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))
{
You try something like the following because you only need to register once:
ClientCredentials deviceCredentials;
if ((CRMSettings.Default.DeviceID == String.Empty) || (CRMSettings.Default.DevicePassword == String.Empty))
{
deviceCredentials = Microsoft.Crm.Services.Utility.DeviceIdManager.RegisterDevice();
}
else
{
deviceCredentials = new ClientCredentials();
deviceCredentials.UserName.UserName = CRMSettings.Default.DeviceID;
deviceCredentials.UserName.Password = CRMSettings.Default.DevicePassword;
}
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, deviceCredentials))
{
I have had issues in the past where I get an "already registered" response from the RegisterDevice call.
I would also dump out the Device ID and Password so you can see if they are being set.

SSRS Report Viewer: request failed with HTTP status 401

I've spent a lot time trying to figure this one out, but without luck - so I will try to post the question here.
I am running 2 ASP.NET websites on the same server. Both websites are running on IIS 7.5 + .NET 4. The sites use the SSRS Report Viewer to show reports from an another server.
We recently moved both the websites and RS to new servers (switching from RS 2005 to RS 2008 and switching from IIS 7.0 to IIS 7.5). However, after moved to the new servers, one of the websites are unable to view the reporting services, as we get the following error:
request failed with HTTP status 401
The strange thing is, that the Report Viewer is configured exactly the same way in the two websites (simply copy pasted between the two). Further, using the "working website", we are able to view the reports belonging to both websites - and using the other website, we are unable to view any of the reports.
The authorization looks like this in both cases:
Credentials:
[Serializable]
public sealed class ReportServerCreditentials : IReportServerCredentials
{
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get
{
string userName = ConfigurationManager.AppSettings["ReportViewerUser"];
string password = ConfigurationManager.AppSettings["ReportViewerPassword"];
string domain = ConfigurationManager.AppSettings["ReportViewerDomain"];
return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
}
Report Viewer usage
public partial class ReportServicesViewer : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
string reportingFolder = ConfigurationManager.AppSettings["ReportingFolder"];
showReport(string.Format("/{0}/{1}", reportingFolder, Request.QueryString["report"]));
}
}
private void showReport(string reportPath)
{
RevReport.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
RevReport.ServerReport.ReportServerCredentials = new ReportServerCreditentials();
RevReport.ServerReport.ReportPath = reportPath;
}
}
In aspx:
<rsweb:ReportViewer ID="RevReport" runat="server" Height="100%" Width="100%" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" ZoomMode="Percent" ZoomPercent="100"></rsweb:ReportViewer>
Other observations
At one point, we tried to monitor the traffic between the website and RS using Fiddler, but somehow the communication actually worked in this case.
However, when I tried this at a later point, Fiddler gave the following response:
[Fiddler] The socket connection to <servername> failed. <br />ErrorCode: 10061. <br />No connection could be made because the target machine actively refused it 10.0.0.17:443
I am not sure how exactly to interpret this, as we are not using SSL for the Website <-> RS communication.
Any advice would be greatly appreciated.
I had the similar issue when we built new SSRS server. Web application was not able to connect to report server. I was able to solve the issue by doing these:
Enable Kerberos Authentication on the server
Set spn(server principal names) on the server
enable the impersonation in web application

Output cache is not working .net4.0

We are working on a asp.net site with .net framework 4.0. and we tried to incorporate output cache for it.
But unfortunately it is not worked. Later we found removing Microsoft security update KB2656351 will solve the problem.
I want to know whethere is there any other way to do this without removing the update.
This issue is there only when you install the above mention update and there is a cookies on the response. No matter if cookies contains in request. Found a workaround to fix this problem. I have created a custom HTTPModule and copy all available cookies from the response(including newly added cookies) to the Context.Items. then clear all the cookies available in the response.
In the next step, read the object stored in the Context.items and add back to the response. So when output cache provider is trying to cache the page there is no cookies in the response. so it works as usual. and then adding the cookies back.
public void Init(HttpApplication context)
{
context.PostReleaseRequestState += new EventHandler(OnPostReleaseRequestState);
context.PostUpdateRequestCache += new EventHandler(OnPostUpdateRequestCache);
}
public void OnPostReleaseRequestState(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
HttpCookieCollection cookieCollection = new HttpCookieCollection();
foreach (string item in context.Response.Cookies)
{
HttpCookie tempCookie = context.Response.Cookies[item];
HttpCookie cookie = new HttpCookie(tempCookie.Name) { Value = tempCookie.Value, Expires = tempCookie.Expires, Domain = tempCookie.Domain, Path = tempCookie.Path };
cookieCollection.Add(cookie);
}
context.Items["cookieCollection"] = cookieCollection;
context.Response.Cookies.Clear();
}
public void OnPostUpdateRequestCache(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
HttpCookieCollection cookieCollection = (HttpCookieCollection)context.Items["cookieCollection"];
if (cookieCollection != null)
{
foreach (string item in cookieCollection)
{
context.Response.Cookies.Add(cookieCollection[item]);
}
}
}
There was some problem reported here for this update, and repairing .net Framework 4 worked. It might be because of the corruption of .net Framework or the order in which framework and IIS is installed, which de-registers ASP.Net, so we need to register ASP.Net specifically, which sometimes causes these issue.
I would suggest to repair .Net framework, and the registering ASP.Net separately to see if that works.

Resources