Unusual error in Clients website - c#

I just created an account on my client's website (which I build for him). I have tested this website extensively and could not find any problems - 2 years ago. I've since tested it to make sure it's all running smoothly every month since the website was released.
I just created a new account on his website just now, and I get this error:
Server Error in '/' Application.
Mailbox unavailable. The server response was: <me#myemail.com> No such user here
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: <me#myemail.com> No such user here
Source Error:
Line 62: HttpUtility.UrlEncode(token));
Line 63:
Line 64: WebMail.Send(
Line 65: email,
Line 66: "Please confirm your Account.",
Source File: d:\HostingSpaces\website\website.com.au\wwwroot\Protected\Account\Register.cshtml Line: 64
Stack Trace:
[SmtpFailedRecipientException: Mailbox unavailable. The server response was: <me#myemail.com> No such user here]
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +1229659
System.Net.Mail.SmtpClient.Send(MailMessage message) +1772
System.Web.Helpers.WebMail.Send(String to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1 additionalHeaders, String bcc, String contentEncoding, String headerEncoding, String priority, String replyTo) +686
ASP._Page_Protected_Account_Register_cshtml.Execute() in d:\HostingSpaces\website\website.com.au\wwwroot\Protected\Account\Register.cshtml:64
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +208
System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +68
System.Web.WebPages.WebPage.ExecutePageHierarchy() +123
System.Web.WebPages.StartPage.RunPage() +19
System.Web.WebPages.StartPage.ExecutePageHierarchy() +67
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +121
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
What the??? The email address listed down there is the email address I used to create the account. After getting this error, I then logged into that email account online - and it's there - with all my mails. So the user does exist. So then why does WebPages framework thing that this user does not exist when trying to send an email confirmation to it?
The email variable you see up there in the code - it's value is listed in the exception itself.

It may happen that for a fraction of second the mailbox was unavailable for some reasons. try again creating the account and it should be fine.

Related

How to debug SQL Server LINQ expressions? [duplicate]

This question already has answers here:
MSSQL Error 'The underlying provider failed on Open'
(31 answers)
Closed last year.
I have the following piece of code, which works at a customer, but not on my computer:
var result = await db.Configurations.FirstOrDefaultAsync().ConfigureAwait(false);
db is derived from a System.Data.Entity.DbContext, defined in EntityFramework.6.4.0\lib\net45\EntityFramework.dll.
In the corresponding SQL Server database, there is a table "Configurations" and it contains an entry.
When I launch the line of source code, an Exception gets generated (I hereby show the slightly formatted content of the immediate window while asking ? ex):
? ex
{"An exception occurred while initializing the database. See the InnerException for details."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233087
HelpLink: null
InnerException: {"The underlying provider failed on Open."}
Message: "An exception occurred while initializing the database. See the InnerException for details."
Source: "EntityFramework"
StackTrace: " bij System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)\r\n bij System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
bij System.Data.Entity.Internal.LazyInternalContext.<>c.<InitializeDatabase>b__58_0(InternalContext c)
bij System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
bij System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
bij System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
bij System.Data.Entity.Internal.InternalContext.Initialize()
bij System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
bij System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
bij System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
bij System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
bij System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
bij System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source)
bij Project.<GetConfigAsync>d__56.MoveNext() in C:\\Source_Code_Directory\\Source_Code_File.cs:regel 2149"
TargetSite: {Void PerformInitializationAction(System.Action)}
I know this line of code works at customer's system, and I'm working on a restored backup of customer's DB.
What is going wrong and what can I do to fix it (what is the underlying provider)?
Thanks in advance
In the meantime the problem is analysed:
I had taken the backup of the customer's DB and restored it on my PC, but the username, as indicated in the connectionstring in source code, was wrong, hence my application could simply not open the database connection, so now the problem comes down on a database user management issue.
Thanks for all the support.

Reference .pfx file from within my WebSite application

I'm developing a WebSite which consumes a web service but I'm having trouble referencing the client certificate file in my code.
I've added the .pfx file to the solution as shown below.
This is how I try to build the link to the file, and add the client certificate to my service:
var certName = "665300-ws-hg-test.pfx";
var newCertPath = Path.Combine(Environment.CurrentDirectory, #"WebSite2\", certName);
DocArchiveV201101 service = new DocArchiveV201101();
service.ClientCertificates.Add(
new System.Security.Cryptography.X509Certificates.X509Certificate(
newCertPath, certPass));
When printing newCertPath:
C:\Program Files (x86)\IIS Express\WebSite2\665300-ws-hg-test.pfx
The last line of code throws the following error:
System.Security.Cryptography.CryptographicException was unhandled by user code
HResult=-2147024893
Message=the system cannot find the file specified.
Source=mscorlib
StackTrace:
vid System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
vid System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName)
vid System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
vid System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password)
vid ASP._Page_index_cshtml.Execute() i c:\Users\marcus.jacobsson\Documents\Visual Studio 2015\WebSites\WebSite2\index.cshtml:rad 47
vid System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
vid System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
vid System.Web.WebPages.WebPage.ExecutePageHierarchy()
vid System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
vid System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext)
InnerException:
So my question is; How do I build a proper link to reference the 665300-ws-hg-test.pfx file in my project?
You need to use the HostingEnvironment.MapPath method. Furthermore, if the certificate is located in the website root, there is no need to prefix the certificate name with the project folder name:
var newCertPath = System.Web.Hosting.HostingEnvironment.MapPath(#"~\" + certName);

An error occurred while connecting to Firefox ---> System.IO.IOException: The directory is not empty

I am working with selenium the last months. I use VS 2013 C#. Most of the time i am using webdriver.dll (2.39.0.0) for firefox (31.0.0.5310), because my testautomation (coded ui tests)
ran pretty stable with it. but now i get randomly this error:
> OpenQA.Selenium.WebDriverException: An error occurred while connecting to Firefox ---> System.IO.IOException: The directory is not empty.
Result StackTrace:
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at OpenQA.Selenium.Firefox.FirefoxExtension.Install(String profileDir) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxExtension.cs:line 106
at OpenQA.Selenium.Firefox.FirefoxProfile.InstallExtensions() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxProfile.cs:line 357
at OpenQA.Selenium.Firefox.FirefoxProfile.WriteToDisk() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxProfile.cs:line 254
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\Internal\ExtensionConnection.cs:line 90
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxDriver.cs:line 225
--- End of inner exception stack trace ---
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Firefox\FirefoxDriver.cs:line 231
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 88
at Testcase1.UIMap.BrowserSettingsFF() in c:***************\UIMap.cs:line 609
at Testcase1.UIMap.InitDriver() in c:***************\UIMap.cs:line 678
I run it on 2 devices working with TFS. On one device it happens much more often.
I could not figure out the problem by now. Has anyone the same problem?

SocketException being thrown when attempting to store sessionState in AppFabricCache for windows Azure webservice

I am attempting a simple example project to get to know how to configure a Windows Azure Cloud service to use Co-located caching.
I am using VS2010 and have followed this example but when I get to the end of the section on co-located caching, I cannot run my project locally. It worked fine when
I am getting the following exceptions: (I hope it's readable..)
Error in '/' Application.
The requested name is valid, but no data of the requested type was found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SocketException (0x2afc): The requested name is valid, but no data of the requested type was found]
Microsoft.ApplicationServer.Caching.AsyncResultNoResult.EndInvoke() +202
Microsoft.ApplicationServer.Caching.AsyncResult`1.EndInvoke() +40
Microsoft.ApplicationServer.Caching.SocketConnectionFactory.EndConnect(IAsyncResult asyncResult) +75
Microsoft.ApplicationServer.Caching.TcpClientChannelFactory.TcpConnectionCallback(IAsyncResult result) +182
[DataCacheException: ErrorCode:SubStatus:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.). Additional Information : The client was trying to communicate with the server: net.tcp://SessionStateDemo:24233.]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable1 servers, RequestBody request, Func3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +1313
Microsoft.ApplicationServer.Caching.<>c__DisplayClass5.b__2(RequestBody req) +198
Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func2 delegate, EndpointID& destination) +121
Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable1 servers) +1225
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1104
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler1 fetchingHandler, EventHandler1 fetchedHandler) +306
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler1 cacheFetching, EventHandler1 cacheFetched) +399
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +59
System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +160
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +340
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1269
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12698078
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Can anyone tell me what is happening here? How can I fix this?
Is there something missing in that tutorial that I need to do?
EDIT: I am using VS2010 Professional, with Windows Azure SDK 2.1. Widnows Azure Cache package is v2.1.0.
Relevant web.config sections:
<system.web>
...
<!-- Windows Azure Caching session state provider -->
<sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
<providers>
<add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/>
</providers>
</sessionState>
...
<sytem.web>
<dataCacheClients>
<dataCacheClient name="default">
<!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
<autoDiscover isEnabled="true" identifier="SessionStateDemo" />
</dataCacheClient>
</dataCacheClients>
Based on this thread it looks like the Windows Azure Cloud Service must be a startup project to work properly. Otherwise the Windows Azure Runtime won't initialize what causes the SocketExceptions.

Server Error in '/' Application. Unspecified error [ 5,sqlcese40.dll ]

Can somebody please help me?
After receiving an email from Google yesterday that advised a couple of links in my site (www.bigint.biz) were broken, I repaired them. Then I made a change to the sitemap.
Afterwards, when accessing the site I received the message: Server Error in '/' Application, Runtime Error, This tag should then have its "mode" attribute set to "Off".
So, I put the site exactly back how it was before the changes to the sitemap; but, I received
an internal server error 500 error message.
Then, I removed the whole site from the host provider and uploaded it again with the original version that worked fine with no joy.
Since, I have set the customErrors tag "mode" attribute to "Off" to get a more detailed error message - below:
Server Error in '/' Application.
Unspecified error [ 5,sqlcese40.dll ]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlServerCe.SqlCeException: Unspecified error [ 5,sqlcese40.dll ]
Source Error: Line 2: #{ Line 3: Line 4: WebSecurity.InitializeDatabaseConnection("PhotoGallery", "UserProfile", "UserId", "Email", true);
Source File: \web-123win\winpackage22\XXX.COM\web\content_AppStart.cshtml Line: 4
Stack Trace:
[SqlCeException (0x80004005): Unspecified error [ 5,sqlcese40.dll ]]
System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) +2182
System.Data.SqlServerCe.SqlCeConnection.Open() +47
WebMatrix.Data.Database.EnsureConnectionOpen() +44
WebMatrix.Data.<QueryInternal>d__0.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +164
WebMatrix.Data.Database.QuerySingle(String commandText, Object[] args) +103
WebMatrix.WebData.DatabaseWrapper.QuerySingle(String commandText, Object[] parameters) +14
WebMatrix.WebData.SimpleMembershipProvider.CheckTableExists(IDatabase db, String tableName) +57
WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +49
WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +73
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
ASP._Page__appstart_cshtml.Execute() in \\web-123win\winpackage22\bigint.biz\www.bigint.biz\web\content\_AppStart.cshtml:4
System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__0() +65
System.Web.WebPages.ApplicationStartPage.<GetSafeExecuteStartPageThunk>b__3(Action action) +7
System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +78
System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +184
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +30
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +96
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +170
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +126
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application) +71
System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +127
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
I noticed that when I was uploading the site again using FileZilla Client that 4 files failed to copy to the host; however, the same files are in the host bin directory as they did not originally delete for some reason - access rights I think. The files are:
web/content/bin/X86/sqlceer40ENN.dll
web/content/bin/X86/sqlceqp40.dll
web/content/bin/X86/sqlcese40.dll
web/content/bin/X86/sqlceme40.dll
Is this just coincidence, as the error message references one of these files?
Any help would be really appreciated.
Thank you.
EDIT - I have found a little more info here but I am struggling to understand how it can help me: http://www.blakepell.com/Blog/?p=227
I have got the site back up and running for the minute by removing: WebSecurity.InitializeDatabaseConnection("PhotoGallery", "UserProfile", "UserId", "Email", true);
But the issue still exists
I picked this problem up again today all this time later and found the solution with research. This is how I got there.
Replacing the dll files as recommended above didn't work before.
So, I started again by switching off my custom errors page which enabled me to get to get to the error code again.
I Googled the error and research pointed to a connection string issue or a folder permissions issue.
It's a good job I checked the permissions again because I previously set the folder permissions in the App_Data folder where the .sdf database was to enable read and write access using FileZilla but nothing actually changed. It seemed to work because changes appeared to cascade down through all the sub directories, but it didn't work.
The permissions were not actually changed using the FTP method although it looked like it had happened. I only found out because another post that I saw today suggested changing permissions through the control panel so I went back there to check them only to see a padlock by the folders.
So, I unlocked the folder permissions on App_Data correctly this time in the control panel file manager. I then un-commented the web security code below in the _AppStart page again and tried the site online and it worked.
Finally, I set custom errors back to on.
The moral is use the control panel and not FTP client to change folder permissions on hosted folders. I hope this helps someone else.

Categories

Resources